CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Need to strip part of string

 



aceall
Novice

Mar 26, 2010, 2:42 AM

Post #1 of 3 (3771 views)
Need to strip part of string Can't Post

I would like to strip this string www.domain.somedomnain.something.com and get only "domain.somedomain.something". I used /^[^.]*.//. It removes
the first part i.e www; I'd like to get ".com" also removed. Any help will be appreciated.

-thanks


rovf
Veteran

Mar 26, 2010, 3:09 AM

Post #2 of 3 (3769 views)
Re: [aceall] Need to strip part of string [In reply to] Can't Post

Like ^ anchors to the start of the string, $ anchors to the end of the string. Example:

Code
s/^www\.(.*)\.com$/$1/



aceall
Novice

Mar 26, 2010, 9:05 AM

Post #3 of 3 (3762 views)
Re: [rovf] Need to strip part of string [In reply to] Can't Post

Thank you rovf!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives