revert back escapeRegExp
This commit is contained in:
parent
7b7c672d6e
commit
e4d9d7ac4a
|
@ -1,6 +1,5 @@
|
|||
import { App, Notice, TFile } from 'obsidian';
|
||||
import BulkRenamePlugin from '../../main';
|
||||
import XRegExp from 'xregexp';
|
||||
|
||||
export const getFilesNamesInDirectory = (plugin: BulkRenamePlugin) => {
|
||||
const { fileNames } = plugin.settings;
|
||||
|
@ -78,6 +77,9 @@ export const renameFilesInObsidian = async (
|
|||
new Notice('successfully renamed all files');
|
||||
};
|
||||
|
||||
let reRegExpChar = /[\\^$.*+?()[\]{}]/g,
|
||||
reHasRegExpChar = RegExp(reRegExpChar.source);
|
||||
|
||||
export function escapeRegExp(s: string) {
|
||||
return XRegExp.escape(s);
|
||||
return s && reHasRegExpChar.test(s) ? s.replace(reRegExpChar, '\\$&') : s;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { TextInputSuggest } from './suggest';
|
|||
import { REGEXP_FLAGS, RegExpFlag } from '../constants/RegExpFlags';
|
||||
|
||||
export class RegExpFlagsSuggest extends TextInputSuggest<RegExpFlag> {
|
||||
// @ts-ignore TODO refactor types types
|
||||
// @ts-ignore TODO refactor types
|
||||
getSuggestions() {
|
||||
return REGEXP_FLAGS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue