Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-03-31 14:28
Flavor·PCRE2 (PHP)

/
^([^_\n]+)(?(?=_)|(?=\.jpg))
/
mg
Open regex in editor

Description

Another rendition of the previous expression, without the lazy quantification. Here, the expression will match any character except for the underscore character, so if there is an underscore, it will stop and evaluate the lookahead.

I wonder which one is faster

Submitted by anonymous