3 ms·
> - Exclude a delimiter from the search space, like using [^>]*?> rather than .*?> or worse yet .*> Or indeed: (?!>).*?
by Jenk 6y ago
> - Exclude a delimiter from the search space, like using [^>]*?> rather than .*?> or worse yet .*>
Or indeed:
(?!>).*?
- rstuart4133 6y agoNot quite. This works: (?:(?!>).)*>? But that is a very long winded way of writing: [^>]*?> which is long way of writing: [^>]*>
- Jenk 6y agoI was missing the trailing > in my pattern but you are still right (as is the article) It's been fun to note the benchmarks: all tested against the string: <a href="sdfsdf">sefsefsefsef</a> 1. (?!>).*?> 2 matches, 41 steps 2. (?:(?!>).)*>? 3 matches, 142 steps 3. (typo?) (?:(?!>).)*?> 2 matches, 161 steps 4. [^>]*?> 2 matches, 6 steps 5. [^>]*> 2 matches, 6 steps