Regex: match a word in a string but only when line doesn't contain a slash -


i want match word in string, when string doesn't contain //

example: match word books

this should match:

i read books.

this should not match.

// read books.

to match word, have created regex:

(?<=.)books(?=\s*)

but how ignore strings contains //?

additional info:

  • // in front of word match.

  • // not @ beginning of string. leading whitespaces possible.

  • i want match word can replace in next step.

  • i want use in replace in files function of visual studio 2013.

thank efforts.

wiktorstribiżew wrote solution question in comment.

the solution: (?<!//.*?)(books|spoons|shelves)


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -