$data = "<Data>hello</Data>";
preg_match_all("/\<Data\>[.]+\<\/Data\>/", $data, $match);
print_r($match);
This returns:
Array ( [0] => Array ( ) )
So I am guessing that a match is not made?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you wanted to use / as the delimiter:
The main problem was that a
.inside a character class matches a literal period. Also, using a different delimiter eliminates escaping. Note that you don’t have to escape<either way. If you want to be able to extract the inner value, use:“hello” will now be in
$matches[1]in your example. Note that regex is not suited for parsing XML, so switch to a real parser for anything non-trivial.