![]() | | ||||||||
| | #1 |
| Advanced Warrior War Room Member Join Date: Aug 2008 Location: Baguio City , Philippines.
Posts: 676
Thanks: 17
Thanked 32 Times in 26 Posts
|
Please help I am working for more than 3 hours now this problem but I can't think or find way to correct it... my regular expression is like this %<h[^>]+>(.*)</h.>%i It works perfectly if the string look like this Code: <H1><A NAME="SECTION000300000000000000000">2 Simple Patterns</A></H1> But if string will look like this Code: <H1><A NAME="SECTION000300000000000000000">2 Simple Patterns </A> </H1> I guess the problem is the line break or not sure.. Thanks in advance |
| Cheap Spun Articles for only $0.29 per spun article. Link Building Services The BEST & Cheapest solution of your link building needs | |
| | |
| | #3 |
| Active Warrior Join Date: Aug 2007 Location: , , .
Posts: 54
Thanks: 0
Thanked 10 Times in 3 Posts
|
Use the 's' pattern modifier so that the (.*) will also match any newlines in the string. For more details, you can read this: PHP: Possible modifiers in regex patterns - Manual |
| | |
| | #4 |
| Took The Red Pill War Room Member Join Date: Apr 2006 Location: Here and Now
Posts: 374
Thanks: 124
Thanked 106 Times in 64 Posts
|
Hi, maybe you could just strip out all the newlines before applying your regex, as they have no meaning in HTML anyway. $string = str_replace("\n", "", $string); $string = str_replace("\r", "", $string); |
| | |
| | #5 |
| HyperActive Warrior War Room Member Join Date: Jan 2009
Posts: 134
Thanks: 10
Thanked 30 Times in 8 Posts
|
I would do something like this: $string = str_replace(array("\n", "\r"), array("", ""), $string); and then use the following code: preg_match("#<h[^>]+>(.*)</h.>#i", $string, $match); $your_result = $match[1]; |
| Try our Revolutionary Article Rewriter (Before All Spots Are Taken!) and Build 1000's of Highly Relevant Backlinks! (Your Traffic will Explode from this!) One of RAVING Spin Rewriter Reviews: "Aaron, this is 20 years ahead of the competition!" | |
| | |
![]() |
|
| Tags |
| express, php, problem, regular |
| Thread Tools | |
| |
![]() |