Please, what is the correct php code, using a regex pattern, to get $output
from $string
?
$string = 'xmlns(ns=http://testurl.com/now)xpointer(//section/datePublished/text())';
Generalizing:
$string = 'string1(string1_1)string2(string2_1)';
Brackets can be recursive (as text()
).
i.e. string1_1
and/or string2_1
may contain other brackets.
$string = 'string1(string1_1())string2(string2_1()string2_2());
Knowing the brackets prefix xmlns
, I need the regex pattern to get //section/datePublished/text()
, i.e. knowing string1
I need the regex pattern to get string1_1
(or string1_1()
).
Knowing the brackets prefix xpointer
, I need the regex pattern to get ns=http://testurl.com/now
, i.e. knowing string2
I need the regex pattern to get string2_1
(or string2_1()string2_2(
).
Can you explain the process?