php - Regular expressions - \| not works -


i have problem regular expression. have code:

<div class="textpremium">premium access 25.04.2014 | 20:59<br>server: on | bandwidth: 200mb<br /></div> 

i want match:

"25.04.2014" (date)

"20:59" (time)

"200" (bandwidth)

here regular expression:

 <div class=\"textpremium\">premium access (.*) \| (.*)<br>server: on | bandwidth: (.*)mb<br><\/div> 

i matched date , time, can't match bandwidth. adding \ before | doesn't work.

try updated expression:

<div class="textpremium">premium access (.*) \| (.*)<br\s*/?>server: on \| bandwidth: (.*)mb<br\s*/?></div> 

as can see in comment, trying match <br> when line break formatted <br />. html not regular language, , should not use regex attempt match it.

however, improved expression match both <br> , <br /> using <br\s*/?>. allow 0+ characters of whitespace followed optional /. note, changed delimiters / ~ didn't need escape ever /.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -