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...
TextPad has two types of search commands, both in the SEARCH menu: FIND and FIND IN FILES. The first is shown in Figure 1a. When working with regular expressions, make sure that the REGULAR EXPRESSION dialogue box is activated. The regex pattern is typed into the FIND WHAT box.
Any character (except for the newline character) will be matched by a period in a regular expression; when you literally want a period in a regular expression you need to precede it with a backslash. Many times you'll need to express the idea of the beginning or end of a line or word in a regular expression.
Search multiple words using regexUse | (pipe) operator to specify multiple patterns.
However, to recognize multiple words in any order using regex, I'd suggest the use of quantifier in regex: (\b(james|jack)\b. *){2,} . Unlike lookaround or mode modifier, this works in most regex flavours.
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.
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).*$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With