Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
\A(?:[^\|]+\|){2}\K(?P<foo>[^\|]*)
/
g

Description

The aim of this regex is to extract only the Nth field from a delimited string.

In the example provided the delimited is the pipe character.

You will have to substitute the pipe character for whatever delimiter you are using.

Submitted by 0jag - 8 years ago