namespace StrUtil { param name return export const createSearchKeyword = ( name ) : string => { const outTitle = name . replace ( /\[.+?\]/g , ' ' ) . replace ( /\【.+?\】/g , ' ' ) . replace ( /\(.\)/g , ' ' ) . replace ( / +/g , ' ' ) . trim ( ) ; let delimiter = ' #' ; if ( outTitle . indexOf ( ' #' ) === - 1 ) { delimiter = outTitle . indexOf ( '「' ) === - 1 ? '' : '「' ; } let keyword = [ ] ; if ( delimiter . length > 0 ) { keyword = outTitle . split ( delimiter ) ; } if ( typeof keyword [ 0 ] === 'undefined' || keyword [ 0 ] . length === 0 || keyword [ 0 ] === '' ) { keyword [ 0 ] = outTitle ; } return keyword [ 0 ] ; } ; } export default StrUtil ;