Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(\b[^()]+\b)\s*\(\s*(\b[^()]+\b)\s*\)
/
gm

Description

How do I extract then some text A, some text B and some text C if they are in the format

some text A ( some text B ( some text C)) Please mind that in some cases may be only

some text A ( some text B)

https://stackoverflow.com/questions/69047224/how-to-fetch-text-strings-in-regex-in-the-format-abc

Submitted by anonymous - 3 years ago