sukhoi35
asked on
Trying to find patterns of substring in a larger string in PHP
I am trying to find all sub-strings in a webpage having the following format "<span>*******</span>". Here, **** can be any text;. So the output array should contain something like:
<span>New York</span>
<span>Paris</span>
<span>Sydney</span>
and so on.
I saw that there is a call 'preg_match_all'. Somehow, I couldn't come up with a proper regular expression for the same. Request experts to help me solve this problem.
<span>New York</span>
<span>Paris</span>
<span>Sydney</span>
and so on.
I saw that there is a call 'preg_match_all'. Somehow, I couldn't come up with a proper regular expression for the same. Request experts to help me solve this problem.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Any ideas? :)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thakns
ASKER
all text between the patterns:
</span>\n,(space)*******, or </span>\n,(space)*******\n
i.e. all text starting with</span> followed by a \n, comma, a single space and ending with a comma or \n. This is the expression i have come up with and it does not seem to work. Can you pls help?
"/\<\/span\>\\n,\" \",(.*)(,|\\n)/"