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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -