vendredi 27 février 2015

Regex Inverse of String

I've read many places that its either impossible or inefficient to do inverse matching with Regex but,


I know its possible to Match any WHOLE LINE that DOES NOT contain a specified Pattern or String using:



^((?!PatternOrString).)*$


But I want to match any CHARACTER(s) (Even those on the same line as the inverse match) that DO NOT contain a specified pattern and/or string.


I've used this code for a while:



\b((?!String).)*\b


But it seems to have trouble with regex patterns, only working with simple alpha-numeric strings


Is there any way to use something similar to the above which can use regex patterns?


I've tried putting the pattern in a group \b((?!(Pattern)).)*\b but that seems to give me mixed results.


Aucun commentaire:

Enregistrer un commentaire