Built this regex in the generator and everything worked as expected, tried cleaning some strings in my app and the app said it was invalid.
The statement is as follows:
const reg = /(?i)-TeamMember$|-TeamLead$/; testString = testString.replace(reg, "");
Trying to run the application results in the following error:
模块解析失败:无效的正则表达式:/(?i)-StringA$|-StringB$/: 无效的分组(199:21) 文件已使用以下加载器进行处理: * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js * ./node_modules/@ngtools/webpack/src/ivy/index.js 您可能需要额外的加载器来处理这些加载器的结果。
Tried this in the generator and everything works as expected, the goal is to remove the suffix from the string if it matches any of the provided strings and ignore case.
P粉5628459412023-09-11 09:02:52
JavaScript has no built-in case-insensitive inline flag. Instead, you should use the case-insensitive flag /i
const reg = /-TeamMember$|-TeamLead$/i; testString = testString.replace(reg, "");
You can read more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase