Regular Expressions 101

Community Patterns

Get the first 2 terms in path using forward slash.

0

Regular Expression
PCRE (PHP <7.3)

/
\/(.*?)\/\w+\/
/
gm

Description

At first the objective was to get the string between the first and third slash but, re-working the problem, it was simpler to retrieve the first word between slashes and a subsequent word.

Submitted by anonymous - 5 years ago