regex - Exclude Matches which start with '#' -


i using simple regex plain text files:

\([a-za-z]*\) 

i matches like:

...(test)..., ...(next)..., ...(warning)... , on

is possible exclude matches start #? example:

 #  caught stealing (warning)   (3300-3599) 

i have tried lot , came this:

(?:^\s*?#.*)|(\([a-za-z0-9\s\-]*\)) 

now need display matches of 1st capturing group, don't know how. can give tip?

this not straight-forward looks.

normally you'd use lookarounds this, case pretty unorthodox. want non-line related results (as line can have number of results) line related requirement (the absence of #).

lookarounds line-specific , have 1 result.

my solution:

\s*?#.*(?:\n|$)|(\([a-za-z0-9\s\-]*\))

demo

you won't avoid having results within capture groups i'm afraid. in case, of results $1. idea describe possibility of commented line, , if it's not met, describe how items you're interested look. since commented line option first, items within won't tested

i changed regex contain spaces, dashes , numbers have more cases of (content123) , alike. if don't want that, discard changes , use \s*?#.*(?:\n|$)|(\([a-za-z]*\))

there other ways this, 1 had success with.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -