Page 1 of 1

how to convert to small caps

Posted: Wed Dec 13, 2006 2:11 pm
by mramardeeepsingh
hi friends
i want to know that how can i replace the entire content in <..............> tags.

for example
i have a code
<STRONG><I><B><FONT COLOR="red">Example Text</FONT></B></I></STRONG>

and i want to convert the html tags to small caps without converting the text i.e Example Text.

<STRONG> should be <strong>
<I> should be
<FONT COLOR="red"> should be <font color="red">

but keeping the text i.e Example Text intact.
due to which i can't use strtolower.

please tell me how to convert the html tags into smallcaps.
what regular expression to use so that i get

<strong><font color="red"><b>Example Text</b></font></strong>

in simple words i want html tags to be converted to small caps, remaining the text intact.

please help

Posted: Wed Dec 13, 2006 2:14 pm
by Nathaniel
You'll want to use preg_replace.

Posted: Wed Dec 13, 2006 2:20 pm
by feyd
I'd recommend preg_replace_callback() over preg_replace(). Security concern..

can u provide me the code

Posted: Wed Dec 13, 2006 2:25 pm
by mramardeeepsingh
can you provide me the code for the same.

Posted: Wed Dec 13, 2006 2:27 pm
by feyd
What have you tried? Have you searched our forum? We have had examples of doing similar things...

Posted: Wed Dec 13, 2006 3:19 pm
by mramardeeepsingh
i havent tried anything yet.
i am a newbie.
just got around preg_replace.

can u provide the code

Posted: Wed Dec 13, 2006 3:20 pm
by feyd
I will not just provide the code without some effort seen on your part.

Posted: Wed Dec 13, 2006 3:31 pm
by mramardeeepsingh
i said i am a newbie.
i dont have any idea how to do that.

if i was aware, then i wont be posting on the forum.

anyways if dont want to help, then its ok.
never mind.

thanks

Posted: Wed Dec 13, 2006 3:34 pm
by feyd
We are here for you to learn, not do the work for you. If you don't want to attempt to figure it out, then I suggest you search for similar threads.

Posted: Wed Dec 13, 2006 4:03 pm
by volka
If you want to learn about regular expressions start with http://www.regular-expressions.info/tutorial.html

Posted: Wed Dec 13, 2006 7:49 pm
by RobertGonzalez
Or you could read the manual for preg_replace_callback() and preg_replace(). Seriously though, very few people here are going to write your code for you. At the very least, give it a shot. If what you try fails, post your code so we can see what you are doing and help walk you through it. A lot of us here are more than happy to help you figure your problems out. But, like I said, few of us will actually solve your problems for you.

Posted: Wed Dec 13, 2006 11:17 pm
by mramardeeepsingh
thanks for the help buddy.
i will study regular expressions.

thanks man.