regex - Regular expression to fetch lines evaluating only one part of a string, java -


i'm trying find regular expression match part of pattern

for example text :

goodclass.nicemethod badclass.nicemethod badclass2.nicemethod verybadclass.nicemethod goodclass.nicemethod badclass.nicemethod badclass2.nicemethod goodclass.nicemethod 

how can lines 'nicemethod' not follow 'goodclass'

you can use negative lookbehind:

string regex = "(?<!goodclass\\.)\\bnicemethod\\b"; 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -