简体   繁体   English

如何创建正则表达式来匹配这样的字符串?

[英]How Can I Create a Regular Expression to Match a String Like This?

I am using Cloud9's IDE and want to use their regex search/replace feature to find all lines of code that look like this: 我正在使用Cloud9的IDE,并希望使用其正则表达式搜索/替换功能来查找看起来像这样的所有代码行:

LINE -(xxx, yyy)

Example: 例:

LINE -(135, 400)

I came up with 我想出了

/LINE -\\(\\d{1,3}, \\d{1,3}\\)\\n/g

This works in RegExr but not in Cloud9 . 这在RegExr中有效,但在Cloud9无效 I've tried a few variations without any luck. 我尝试了几种变体,没有任何运气。 Any ideas? 有任何想法吗?

A few notes about Cloud9 find panel using a Regex: 有关使用Regex的Cloud9查找面板的一些说明:

  • You don't need to add the / delimiters 您不需要添加/分隔符
  • The trailing /g is also not needed 尾随的/g也不需要
  • You need to enable regex mode in the find box by clicking on the button that says: .*? 您需要通过单击以下按钮来在查找框中启用正则表达式模式: .*?

I tried the above regex with a dummy file and it worked. 我用一个虚拟文件尝试了上面的正则表达式,它起作用了。 Here's the final find query I gave: 这是我给的最终查找查询:

LINE -\(\d{1,3}, \d{1,3}\)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM