Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another simple one for you guys :)

Status
Not open for further replies.

Buddyholly83

IS-IT--Management
Aug 7, 2005
23
GB
Trying to place occurances of + with ' ' (a space) from a string, and %3a with : from another string like so:
Code:
$four =~ s/"+"/  /;
$five =~ s/"%3a"/:/;

This doesn't do anything :(

Any ideas?
 
Code:
my $str = 'Here+is+some+text%3aand+some+more%3a';
$str =~ s/\+/ /g;
$str =~ s/%3a/:/g;
print $str;
 
Why you quote them when you dont search for quotes?

This is how you should do it
Code:
$_ =~ s/\+/ /g;
$_ =~ s/%3a/:/g;

And if you know that the + or the %3a are not occur more than ones in every line then you don't need the g at the end.
But if there are more than one + in the same line, and more than one %3a then you should use it.


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Sorry rharsh, i guess you are faster than me. :)


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Was using quotes because + and % have purpose in Perl - using quotes was my stab in the dark!

Thanks for the reply - all of them :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top