Grab characters up to a certain character

I

imphasing

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...

Thanks,
Alex
 
G

Glenn Jackman

At 2005-04-21 12:10PM said:
I have a string like so:

imphasing: Hi people.

and I want to replace all the characters up to the ": " with
"<b>imphasing: </b>"

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top