pcre - Regex match with negative look ahead and non greedy -


source string

<html name="abc:///testers/something.txt" in="abc/testers/something.txt" loci="123" sap="abcdefgh="/><html name="abc:///needed.txt" src="abc/needed.txt" location="123" sap="rtyghu"/><html name="abc:///testers/testers3/another.txt" in="abc/testers/testers3/another.txt" loci="123" sap="jhkiopjhg"/><html name="abc:///onemore.txt" src="abc/onemore.txt" location="123" sap="dfrtyu"/> 

how match section starting <html name=" not followed (needed) or (onemore) , ending />

so in string there should 2 matches are

<html name="abc:///testers/something.txt" in="abc/testers/something.txt" loci="123" sap="abcdefgh="/> <html name="abc:///testers/testers3/another.txt" in="abc/testers/testers3/another.txt" loci="123" sap="jhkiopjhg"/> 

i tried - <html name=(?!(needed|onemore)).*?"\/>

it doesnt work confused non greedy , negative lookahead stuffs.

what need use repetition quantifier in addition putting restriction on should give traversing:

<html\s+name="(?![^"]*(?:needed|onemore))[^>]*> 

live demo


Comments

Popular posts from this blog

python - What's the Pythonic way to report nonfatal errors in a parser? -

sql server - Deadlock occuring in Clustered Columnstore index -

angular - Converting AngularJS deffered promise to AngularX observable for JSOM -