Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regexes and URIs

by alfie (Pilgrim)
on Mar 29, 2001 at 21:56 UTC ( #68146=note: print w/replies, xml ) Need Help??


in reply to Regexes and URIs

Do you have the complete URI in a single string or do you have it in a text? The first is quite simple:
($file) = $uri =~ /^.*\/(.*)$/;
You might end up with an empty $file if the URI ends in a / (and therefore uses the default index file).

The later is more complicate, for you have to keep different things in mind:

  • You should change the class of allowed characters to something more strict, to just the allowed characters that are defined in the URI RFC.
  • On the other hand people tend to put allowed URI-characters behind their URIs. Usual character in that range include the dot (`.'), closing brackets (`)') and coma (`,'). Also quotation marks fall in that range. So you should add a 1-character wide character class at the end that doesn't include those, too.
There might be other things that I haven't thought about yet, but I hope you get the image...
--
Alfie

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://68146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-05-17 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (65 votes). Check out past polls.

    Notices?