I am trying to combine 2 different regular expressions with the same name into one and get an error message as follows:
Warning: preg_match (): Compilation failed: the two named subpatterns have the same name at offset 276 ...
One regex looks like this:
'%<div class="artikkelen">[\s\S]*?<h2>(?P<title>[\s\S]*?)</h2>%'
Another is as follows:
'%<div id="article">[\s\S]*?<h1>(?P<title>[\s\S]*?)</h1>%'
I could combine them as follows without problems:
'%(<div class="artikkelen">[\s\S]*?<h2>(?P<title>[\s\S]*?)</h2>|<div id="article">[\s\S]*?<h1>(?P<title2>[\s\S]*?)</h1>)%'
But I do not like it because I use 2 names. I am wondering if there is a better way to solve this problem. Thanks in advance.
Best regards, Box (boxoft ... Simple and excellent)
source
share