Re: [PHP] a regular expression problem - split text
If I got this right : preg_match_all (#\!.*?(.*?)#si,$string,$match); You will have an array ($match[1]) with all your subs in there. -- georgep - Original Message - From: Juan Pablo Aqueveque [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, January 20, 2003 9:11 PM Subject: [PHP] a regular expression problem - split text Hi all I am sorry for the very simple question but I can't doing this. I have a text like this: $text= !-- 1 -- this is January !-- 2 -- this is February !-- 3 -- this is March !-- 4 -- this is April ; OK.. i want to show e.g. this is January in my var $sub_text. How can i doing this using a regular expressions? ?php ereg((help-me-with-a-regulars-expressions-sentence),text,$sub_text); echo $sub_text[0]; ? thanks a lot Juan Pablo Aqueveque [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] a regular expression problem - split text
Hi all I am sorry for the very simple question but I can't doing this. I have a text like this: $text= !-- 1 -- this is January !-- 2 -- this is February !-- 3 -- this is March !-- 4 -- this is April ; OK.. i want to show e.g. this is January in my var $sub_text. How can i doing this using a regular expressions? ?php ereg((help-me-with-a-regulars-expressions-sentence),text,$sub_text); echo $sub_text[0]; ? thanks a lot Juan Pablo Aqueveque [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] a regular expression problem - split text
I have a text like this: $text= !-- 1 -- this is January !-- 2 -- this is February !-- 3 -- this is March !-- 4 -- this is April ; OK.. i want to show e.g. this is January in my var $sub_text. How can i doing this using a regular expressions? This seems to work. preg_match_all(/!-- [0-9]+ --([a-z ]+)/i,$text,$matches); $matches will be an array with the values your after in it. Do a print_r() on it to see how it's structured. Or, if you're text is always like that, you could just match what's between the and characters, too. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php