By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

removing GBP symbol from a string

P: 2
I have some code to adjust data entered into a web page template to use it in a javascript function. This, amongst other things, will remove start and end spaces, replace the inter-word spaces with hyphens, etc etc.

However I am struggling to remove pound () signs.

Is there something different that I need to do for currency symbols?

Any help would be appreciated!

Thanks

Tony

------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Here is the code for the other RegExs:
  2. $idref =~ s/\'//g; # remove '
  3. $idref =~ s/\&amp\; //g; # remove &amp;<space>
  4. $idref =~ s/\& //g; # remove &<space>
  5. $idref =~ s/\,//g; # remove ,
  6. $idref =~ s/\"//g; # remove "
  7. $idref =~ s/\-//g; # remove -
  8. $idref =~ s/\?//g; # remove ?
  9. $idref =~ s/ /_/g; # replace spaces with _
  10.  
Jan 19 '09 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
@TonyN
You can try using the ascii character code to remove them. Also, please use code tags!

Regards,

Jeff
Jan 19 '09 #2

P: 2
Thanks, Jeff. that sent me off on the right direction - I'm sorted now :D


p.s.
This was my first post.. how should I be presenting code within a message?
Jan 19 '09 #3

eWish
Expert 100+
P: 971
Tony,

You place your code inside of the [CODE][/CODE] tags.

--Kevin
Jan 19 '09 #4

Kelicula
Expert 100+
P: 176
FYI: You could also consider combining all those substitutions into one statement with a character class.

Expand|Select|Wrap|Line Numbers
  1.    $idref =~ s/\'//g; # remove '
  2.  $idref =~ s/\&amp\; //g; # remove &amp;<space>
  3.  $idref =~ s/\& //g; # remove &<space>
  4.  $idref =~ s/\,//g; # remove ,
  5.  $idref =~ s/\"//g; # remove "
  6.  $idref =~ s/\-//g; # remove -
  7.  $idref =~ s/\?//g; # remove ?
  8.  $idref =~ s/ /_/g; # replace spaces with _
  9.  
  10. # Change that into this:
  11.  
  12.  
  13. $idref =~ s/[',"-?&]|\&amp\;//g;
  14. $idref =~ s/\s/_/g;
  15.  
  16. # untested.
  17.  
But of course that's just nit picking.
Jan 20 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.