Please help creating search pattern (for findstr.exe)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ensign
Posts: 3
Joined: 08 Sep 2017 07:58

Please help creating search pattern (for findstr.exe)

#1 Post by ensign » 08 Sep 2017 08:27

Hello,

may I ask here for help making the right search pattern.

I'm using findstr.exe (Windows 7).

Text which I like to find in a huge textflile looks like:

: A_BmwThZel_f (123.456) /* sfssfsfsfsf */
or
A_BmwThZel2_f ( -123.0) /* */
or
A_BmwThresholfForSpeedCal_f (3.00023456789) gggg_rrr---ii


Text between A_ and _f may be any letter (capital or not) and number 0-9
Preceeding of A_???_f there might be one ore more blanks or other special signs (like :)
on the right side, between A_???_f and opening bracket ( there might be one ore more spaces. After the closing bracket ) ther might be spaces or other charachters.
Within the brackets () there are numbers, with dot . Values may be negative.

Any idea how to achieve an appropriate regex pattern which works with findstr.exe?

Thanks for any hint.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Please help creating search pattern (for findstr.exe)

#2 Post by aGerman » 08 Sep 2017 10:11

Code: Select all

findstr "\<A_[A-Za-z0-9][A-Za-z0-9]*_f[ ]*([ ]*[-]*[0-9.][0-9.]*[ ]*)" "test.txt"

Note that FINDSTR always outputs the entire line where the pattern was found.

Steffen

ensign
Posts: 3
Joined: 08 Sep 2017 07:58

Re: Please help creating search pattern (for findstr.exe)

#3 Post by ensign » 14 Sep 2017 07:01

aGerman wrote:

Code: Select all

findstr "\<A_[A-Za-z0-9][A-Za-z0-9]*_f[ ]*([ ]*[-]*[0-9.][0-9.]*[ ]*)" "test.txt"

Note that FINDSTR always outputs the entire line where the pattern was found.

Steffen

Thanks !

Post Reply