subtitute a string.

C

Charlie

A string of a http address in the format of xxx.com, xxx.gov or
xxx.org. I want to check and substitute it in just one SINGLE line,
such as:

$value =~ s/xxx//;
#"xxx" could be "com", "gov", or "org".


What will the "xxx" be ?

-CJ
 
T

TF

Charlie said:
A string of a http address in the format of xxx.com, xxx.gov or
xxx.org. I want to check and substitute it in just one SINGLE line,
such as:

$value =~ s/xxx//;
#"xxx" could be "com", "gov", or "org".


What will the "xxx" be ?

-CJ

huh
 
A

Anno Siegel

Charlie said:
A string of a http address in the format of xxx.com, xxx.gov or
xxx.org. I want to check and substitute it in just one SINGLE line,
such as:

$value =~ s/xxx//;
#"xxx" could be "com", "gov", or "org".


What will the "xxx" be ?

How are you doing it in multiple lines, and what's wrong with it?

Anno
 
G

gnari

Charlie said:
A string of a http address in the format of xxx.com, xxx.gov or
xxx.org. I want to check and substitute it in just one SINGLE line,
such as:

$value =~ s/xxx//;
#"xxx" could be "com", "gov", or "org".


What will the "xxx" be ?

the problem here is that you are overloading your xxx

reading your post, one might think that the xxx is one of
the domain without the TLD
the regular expression you want to use
or the TLD (cpm, gov, org , ...)

assuming you want just to remove the TLD and change,
say, foo.bar.com to foo.bar

$value =~ s/\.(com|org|gov)$//;

if you are asking something else, please be more clear

gnari
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top