帮助写简单的正则表达式 [英] Help writting simple regex
本文介绍了帮助写简单的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图编写正则表达式,在文本文件中查找电话号码,但只有在有电话:时才会这样做。在同一行的数字前面。
我创建的表达式如下所示
Hi, i trying to write regular expression that looking for phone number in text file, but only does it if there is "Phone: " in front of number on same line.
Expression i created looks like this
展开 | < span class =codeLinkonclick =selectAll(this);>选择 | 换行 | 行号
推荐答案
您可以在正则表达式中添加您希望看到的任何文本。
例如,如果在您的情况下,电话:在该行的开头,您可以执行以下操作:
You can add any text in your regex that you expect to see.
For instance, if in your case the "Phone:" is at the beginning of the line in question, you could do the following:
展开 | 选择 | Wrap | 行号
它没有为我工作,你能告诉我完整的代码会是什么样的吗?
It does not work for me, could you show me how full code will look like?
问题是我实际上使用支持perl 5编程语言正则表达式的程序,所以你能帮我一下吗添加到我的代码行检查电话:在数字的开头。
The thing is that i actually use program that supports perl 5 programming language regular expressions, so could you please help me just add to my line of code check for "Phone: " in beginning of number.
这篇关于帮助写简单的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文