|
|
| Come for the quick hacks, stay for the epiphanies. | |
| PerlMonks |
Encoding a URL with regular expressions?by Anonymous Monk |
| on Apr 09, 2004 at 09:14 UTC ( [id://343890]=perlquestion: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks; I am having a problem trying to format a url. The last part of my url will be names with spaces between them. Example, if the last name of my url looks like something like: Inn House Company and Services, my url will end like this "http://my.test.com?infor=info2&company_name=Inn" everything after the first word because is followed by space will not be part of the url. What I am trying to do is to replace all the spaces coming from a variable $company_name per example, that has spaces in it to %20, but some how I am still not able to make one that would take any name format. I am wondering is there is a better way to say: I any company name has any spaces between them replace the spaces with %20, here is my regular expression, but as you can see it is not efficient as it should be.
And I do have names like: Soft, Inc. LTD Y.O.U Co. and Services General Help Company It can also make the reg. exp. even more difficulty to match. Thanks for the help. 20040409 Edit by BazB: Changed title from 'Regular Expression'
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||