Regexp Text Bold Or Italic
What I'm trying to achieve: I run a forum, and want people to be able to make text bold or italic using a particular method which is to start the text to be formated with a bracket, and to end the text with a bracket then either i or b (i for italics, and b for bold) For example,
(this is some text)b
Is to be regexp'd to look like:
this is some text
It needs to be with the brackets than any other methods, as I am migrating data from a large system that uses this particular setup. What I've come up with so far is.
$dbRow->message = ereg_replace("[(]+.+[)]i","<i></i>", $dbRow->message);
This leaves in the brackets though, and also the control character (in this case, the i) at the end of the text. Also, the other problem is, that if you have a section of text to be italic, then of normal text, then more of italic, it just makes the whole lot italic.
Posted: 09-06-2006, 12:26 PM
View 3 Replies!
View Related
Bold, Italics, Underline Str_replac'd Using The Same Char For Opening And Closing Tags
I want to write a _very_ simple text parser that would replace a
string like:
"This is text with /italics/, *bold* and _underline_."
and generate automatically something like this:
"This is text with <i>italics</i>, <b>bold</b> and <span
class="underline">underline</span>."
I've found a lot of code snippets explaining how to do BBCode, but
BBCode has different opening and closing pseudo-tags. In my example,
the opening and closing tags are the same (either /, * or _). So I
need something slightly more intelligent that would count the number
of /, * or _ tags, see if that number is even or odd and decide
accordingly if it must replace the char with an opening or closing
tag. (I hope my wording makes sense. It's very clear in my head :-D)
How would you implement that? I reckon it can't be hard, but I just
can't figure how to do it right now!
Posted: July 17th, 2005 12:47 PM
View 3 Replies!
View Related
Make The Text Underline Using GD Library?
Using GD library how to make the text underline.
I have used imagettftext ( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text ) this function for write text to the image. I could not make underline text on image.
Posted: May 28, 2007, 01:18:11 AM
View 3 Replies!
View Related
Regular Expression To Underline A Given Word In A Text...
With the sentence :
"Bordeaux est au bord de l'eau"
How to do to underline, for instance, the word "eau" ? without underlining
the substring of "Bordeaux" ?
I don't know how to isolate the word...
My current code :
$text=eregi_replace("(".stripslashes($word_to_underline]).")","<b>