regex match one string only if line does not contain another string -
regex match one string only if line does not contain another string -
is there general regex matching 1 string, if line not contain string?
e.g want match word apple if line not contain banana. next lines:
apple banana - not match pear apple - matches apple not pear apple pear apple - matches first , sec apple not pear i know
^((?!banana).)*$ will match line not contain banana. can't seem combine matching apple only.
you can utilize pcre regex:
.*banana.*$(*skip)(*f)|\bapple\b working demo regex
Comments
Post a Comment