Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Grab characters up to a certain character

Reply
Thread Tools

Grab characters up to a certain character

 
 
imphasing
Guest
Posts: n/a
 
      04-21-2005
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

 
Reply With Quote
 
 
 
 
Glenn Jackman
Guest
Posts: n/a
 
      04-21-2005
At 2005-04-21 12:10PM, imphasing <> wrote:
> 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>|;


--
Glenn Jackman
NCF Sysadmin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Vista cannot obtain an IP address from certain routers or from certain non-Microsoft DHCP Brian W Wireless Networking 7 01-31-2010 03:46 AM
Binding certain rows to certain columns in GridView? bernard.oflynn@gmail.com ASP .Net 2 03-25-2008 03:49 PM
Finding one certain line in a file is easy but how to look forheadlines and something just under this certain headline? kazaam Ruby 3 08-26-2007 03:34 PM
Expanding certain path to certain node in a JTree arun.hallan@gmail.com Java 0 01-08-2005 08:26 PM
field validation as float with certain integer and certain decimal SAN CAZIANO Javascript 8 10-15-2004 05:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57