Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex expression or in batch

How can I write a regex expression with OR in batch. I have a file and I want to find "aa" or "bb". The file contains these lines:

aa
bb
cc

This is the command I have tryed:

findstr /I /R /C:"aa\|bb" temp.txt

and

findstr /I /R /C:"aa|bb" temp.txt

Can anyone help me with the OR syntax in batch for writing regular expressions.

Thanks.

like image 597
georgiana_e Avatar asked Nov 27 '25 06:11

georgiana_e


1 Answers

Quoted from the doc:

FINDSTR does not support alternation with the pipe character (|) multiple Regular Expressions can be separated with spaces, just the same as separating multiple words (assuming you have not specified a literal search with /C) but this may not be useful if the regex itself contains spaces.

Reference: http://ss64.com/nt/findstr.html

like image 173
Stephan Avatar answered Nov 29 '25 23:11

Stephan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!