我对正则表达式有点新意,我正在寻找一些通配符字符串的多行/实例,例如*8768,*9875,*2353.
我想拉出这些实例(在一个文件中),而不是单独搜索它们.
任何帮助是极大的赞赏.我尝试过像*8768,*9875等等......
wal*_*lyk 54
如果我明白你在问什么,那就是这样的正则表达式:
^(8768|9875|2353)
Run Code Online (Sandbox Code Playgroud)
这仅匹配行首的三组数字字符串.
acd*_*ior 32
要获取包含文本的行8768,9875或者2353使用:
^.*(8768|9875|2353).*$
Run Code Online (Sandbox Code Playgroud)
这是什么意思:
^ from the beginning of the line
.* get any character except \n (0 or more times)
(8768|9875|2353) if the line contains the string '8768' OR '9875' OR '2353'
.* and get any character except \n (0 or more times)
$ until the end of the line
Run Code Online (Sandbox Code Playgroud)
如果你想要文字*字符,你必须逃避它:
^.*(\*8768|\*9875|\*2353).*$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
134792 次 |
| 最近记录: |