Grab characters up to a certain character

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm writing a script, that parses a chat log into an html file, and
I've done a fairly good job so far, it works quite well. But I want to
make the nickname of a person bold. I have a string like so:

imphasing: Hi people.

and I want to replace all the characters up to the ": " with
"<b>imphasing: </b>"
I tried an index, but it didn't seem to return the character position
of ": "...I can't search and replace "imphasing: ", because other
people are going to be talking too.

Any ideas? if I could just get the "imphasing: " into a string, it
would be nice and easy...


Re: Grab characters up to a certain character

Quoted text here. Click to load it

    $string =~ s|^(.*?:)|<b>$1</b>|;

Glenn Jackman
NCF Sysadmin

Site Timeline