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



aceall
Novice

Mar 26, 2010, 2:42 AM


Views: 7917
Need to strip part of string

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


Views: 7915
Re: [aceall] Need to strip part of string

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


Views: 7908
Re: [rovf] Need to strip part of string

Thank you rovf!