Regular Expressions 101

Community Patterns

Get Sku, leave out _# before file extension (version 2)

0

Regular Expression
PCRE2 (PHP >=7.3)

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

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 - 2 years ago