正则表达式:带有分组选择的非运算符

huangapple go评论64阅读模式
英文:

Regex: Not operator with grouped selection

问题

如下模式(currentStore.*?\}.*?=.*?useApp)用于搜索以下模式:

const {currentStore} = useApp();

但我需要一个模式,用于搜索分配currentStore的内容,如下(Not(currentStore.*?\}.*?=.*?useApp)):

currentStore = await MultiStoreService.getStoreInfoByLocation(zipCode, subdistrict);

我的意思是,不符合上述条件的条件,没有获得选项,如果没有合适的解决方案,欢迎提出建议。即使在编辑原始问题时提出建议也是受欢迎的。

英文:

As below pattern (currentStore.*?\}.*?=.*?useApp) which search for a pattern like this:

const {currentStore} = useApp();

But I need a pattern which search for a content where assignation of currentStore is happening like below(Not(currentStore.*?\}.*?=.*?useApp)):

currentStore = await MultiStoreService.getStoreInfoByLocation(zipCode, subdistrict);

I mean conditions which do not follow above conditions
not getting an option, welcoming suggestion if proper solution is not available.
Even if suggestion over edition original question is also welcome.

答案1

得分: 1

匹配任何分配给 currentStore 的行:

^.*?currentStore\W+=[^;]+;

查看在线演示

英文:

To match any line that assigns to currentStore:

^.*?currentStore\W+=[^;]+;

See live demo.

答案2

得分: 1

当前存储 = await\s+[a-zA-Z_][a-zA-Z_0-9].[a-zA-Z_][a-zA-Z_0-9](.*);

英文:

maybe this will help

currentStore = await\s+[a-zA-Z_][a-zA-Z_0-9]*\.[a-zA-Z_][a-zA-Z_0-9]*\(.*\);

huangapple
  • 本文由 发表于 2023年6月26日 00:02:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76551291.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定