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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -