Page 1 of 1

Regular expression

Posted: Fri Dec 19, 2008 10:01 pm
by zerandib
Moved by moderator to Regex forum.

Hello

$nametitle = "15658'>Tattoo funny cool</a></td><";

how can i remove these tags
</a></td><
and
'>

then how to get the out put as
15658
Tattoo funny cool


need help!

Re: Regular expression

Posted: Fri Dec 19, 2008 10:30 pm
by John Cartwright
Regex not required. Take a look at strip_tags()

Re: Regular expression

Posted: Sat Dec 27, 2008 3:02 am
by prometheuzz
A bit of an old thread, but here's a possible way to do it. As already mentioned, the tags can be removed by using the built-in strip_tags function. After doing so, you can split the string with a regex:

Code: Select all

$nametitle = "15658'>Tattoo funny cool</a></td><";
$tokens = preg_split("/[\"'<>]+/", strip_tags($nametitle), 2);
print_r($tokens);
The last parameter, the number two, will cause the split function to split the target string in no more than two sub-strings.

Re: Regular expression

Posted: Thu Jan 15, 2009 11:08 am
by piyushj
regular expression for the only strings that are not generated over {a,b} by the expression (a+ b)* a (a+b)*
reasoning please

Re: Regular expression

Posted: Thu Jan 15, 2009 11:19 am
by piyushj
Write a regular expression for strings that contain atleast one a and one b. show that its capable of generating the strings :

(i) aabbbabaa
(ii) bbbbaaa

Re: Regular expression

Posted: Fri Jan 16, 2009 5:24 am
by prometheuzz
piyushj wrote:Write a regular expression for strings that contain atleast one a and one b. show that its capable of generating the strings :

(i) aabbbabaa
(ii) bbbbaaa
As I suggested three times now: create your own thread instead of hijacking other people's thread.