Regular expression to search multiple strings (Tex

2019-01-22 11:45发布

I'm a bit new to regex and am looking to search for multiple lines/instaces of some wildcard strings such as *8768, *9875, *2353.

I would like to pull all instances of these (within one file) rather than searching them individually.

Any help is greatly appreciated. I've tried things such as *8768,*9875 etc...

标签: regex textpad
3条回答
欢心
2楼-- · 2019-01-22 12:21

If I understand what you are asking, it is a regular expression like this:

^(8768|9875|2353)

This matches the three sets of digit strings at beginning of line only.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-22 12:28

I suggest much better solution. Task in my case: add http://google.com/ path before each record and import multiple fields.

CSV single field value (all images just have filenames, separate by |):
"123.jpg|345.jpg|567.jpg"

Tamper 1st plugin: find and replace by REGEXP: pattern: /([a-zA-Z0-9]*)./ replacement: http://google.com/$1

Tamper 2nd plugin: explode setting: explode by |

In this case you don't need any additinal fields mappings and can use 1 field in CSV

查看更多
别忘想泡老子
4楼-- · 2019-01-22 12:39

To get the lines that contain the texts 8768, 9875 or 2353, use:

^.*(8768|9875|2353).*$

What it means:

^                      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

If you do want the literal * char, you'd have to escape it:

^.*(\*8768|\*9875|\*2353).*$
查看更多
登录 后发表回答