Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(?:[^\|]+\|){2}\K(?P<q>[^\|]*)
/
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 - 7 years ago