Jump to content

Regex This!!


ctcmedia

Recommended Posts

Having a couple of problems with regexing the following code

 

<p>
<strong>10am</strong>
<br/>
<strong>Match 1</strong>
– BLAH BLAH
<br/>
<strong>Match 2</strong>
– BLAH BLAH
<br/>
<strong>Match 3</strong>
– BLAH BLAH
<br/>
<strong>Match 4</strong>
– BLAH BLAH
<br/>
<strong>Match 5</strong>
– BLAH BLAH
<br/>
<strong>Match 6</strong>
– BLAH BLAH
<br/>
<strong>Match 7</strong>
– BLAH BLAH
<br/>
<strong>Match 8</strong>
– BLAH BLAH
<br/>
</p>

 

Namely being I dont know how to any tips, advice, links ??

 

 

thanks

 

Paul

 

 

Link to comment
https://forums.phpfreaks.com/topic/180394-regex-this/
Share on other sites

Only because I'm bored.

 

$This = '<p>
<strong>10am</strong>
<br/>
<strong>Match 1</strong>
– BLAH BLAH
<br/>
<strong>Match 2</strong>
– BLAH BLAH
<br/>
<strong>Match 3</strong>
– BLAH BLAH
<br/>
<strong>Match 4</strong>
– BLAH BLAH
<br/>
<strong>Match 5</strong>
– BLAH BLAH
<br/>
<strong>Match 6</strong>
– BLAH BLAH
<br/>
<strong>Match 7</strong>
– BLAH BLAH
<br/>
<strong>Match 8</strong>
– BLAH BLAH
<br/>
</p>';

$This = preg_replace('~\s?</?p>\s?~i', '', $This);
preg_match_all('~<stong>(.*?)</strong>\s- [\S]+\s<br/>\s~', $This, $M);

print_r($M);

 

Note that this is untested

Link to comment
https://forums.phpfreaks.com/topic/180394-regex-this/#findComment-951671
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.