Regex selecting by exclusion -


("<?xml version=\"1.0\" standalone=\"yes\"?>  <datapacket version=\"2.0\" version dada version 

let's have sample text , want select version or version words not preceded xml , datapacket tags.

so far have:

((\<?xml |\<datapacket )(v|v)ersion)  

which selects ones don't want see. how go here selecting other ones

with (\<?xml |\<datapacket )?[v|v]ersion can select of items, both needed , ones not qualify, need somehow exclude 2 selections have tags part.

try following (in notepad++):

(?<!<\?xml\s|<datapacket\s)\b[vv]ersion\b 

this works if there's 1 whitespace character before version; that's limitation of regex engine notepad++ uses.

in visual studio 2010 or higher, limitation removed:

(?<!<\?xml\s+|<datapacket\s+)\b[vv]ersion\b 

would work there.


Comments