in reply to match with exception
This only does a lookahead after finding an 'x', which ought to be faster than doing a lookahead for each character (which is what /^(?:(?!xyz).)*$/s based solutions do). Of course, the performance difference may not be relevant for you. If needed, the lookahead can entirely be eliminated, but that requires a more complicated regexp - and then I would have to think./^[^x]*(?:x(?!yz)[^x]*)*$/
|
|---|