Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Regexp Function Preg_match_all(), preg_match_all() - Help me
electron
post Jul 30 2006, 04:23 PM
Post #1


Premium Member
********

Group: Members
Posts: 162
Joined: 10-May 06
Member No.: 23,375



Hi,

I got a new problem which has caused me to go mad but no solution.
preg_match_all() - is the problem.

I have something like this:

CODE

[ol]
[li]Test1[/li]
[li]Test2[/li]
[li]Test3[/li]
[li]Test4[/li]
[li]Test5[/li]
[/ol]

Some text.Some text.Some text.

[ol]
[li]Test1[/li]
[ol]
[li]Test1[/li]
[li]Test2[/li]
[li]Test3[/li]
[li]Test4[/li]
[li]Test5[/li]
[/ol]
[li]Test2[/li]
[li]Test3[/li]
[li]Test4[/li]
[li]Test5[/li]
[/ol]


My RegExp is the following:
CODE

preg_match_all("/(\[ol\])(.*)(\[\/ol\])/iUx", $text, $matches, PREG_SET_ORDER);


Now this function gets 2 matches from the given text :
Match 1:
CODE
[ol]
[li]Test1[/li]
[li]Test2[/li]
[li]Test3[/li]
[li]Test4[/li]
[li]Test5[/li]
[/ol]


Match 2:
CODE
[ol]
[li]Test1[/li]
[ol]
[li]Test1[/li]
[li]Test2[/li]
[li]Test3[/li]
[li]Test4[/li]
[li]Test5[/li]
[/ol]


It takes the [/ol] of the nested element first.

I wanted that the preg_match_all() function matches the second match including the nested OR it should give me three matches.

If i use Greedy RegExp then it takes the whole thing as One Match including the text between the two seperated [OL]'s.

Is my REGEXP wrong or something.I tried lookaheads also but nothing.

Please help me with this.
I need it . This thing is going in my mind and does not let me live with peace.

Thanks and have a good day.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Need Help With The Header() Function(2)
  3. Question For The If And Echo Function(2)
  4. Need Help With Php(2)
  5. php header() function help needed(4)
  6. How To Use A Link To Call Function In Php?(8)
  7. Include File.php?id=something(13)
  8. How To Enable Mail() Function In Php(1)
  9. Question About The Mail() Function(2)
  10. Help With Preg_replace(3)
  11. Explode Function Help(1)
  12. Preg_replace Problems(7)
  13. How Good Is This Data Cleaning Function?(2)
  14. The Extract() Function(6)
  15. Error With Joomla Template(1)
  1. [php] Header Function(2)
  2. [php](simple) Using Functions To Combine Values In A Form(2)
  3. Mail() Clone(5)
  4. The Best Zip Function(1)
  5. Validation Script - Detecting Illegal Characters(0)
  6. Php Explode Function Help(4)
  7. How To Check If Fsockopen Function Is Enabled?(2)
  8. Arrays Outside A Function(3)
  9. Endif function?(6)
  10. Php Preg Replace(1)
  11. Preg Replace Problem(1)
  12. A Simple Preg_replace Help Please.(2)
  13. PHP Function To Add Previous and Next Page Feature(2)


 



- Lo-Fi Version Time is now: 28th August 2008 - 10:00 AM