Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Regex for extracting a domain name from a string.

by Cody Pendant (Prior)
on Feb 28, 2008 at 03:25 UTC ( [id://670809]=note: print w/replies, xml ) Need Help??


in reply to Regex for extracting a domain name from a string.

Short answer, this problem is too difficult for "a regex" to handle. You need a module.



Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...
  • Comment on Re: Regex for extracting a domain name from a string.

Replies are listed 'Best First'.
Re^2: Regex for extracting a domain name from a string.
by sundialsvc4 (Abbot) on Feb 28, 2008 at 03:45 UTC

    Indeed. My take on the matter is ... what this person wants to get is:   “this-or-that part of ‘a domain name.’” And it so happens that the “obvious way” to get there is... “well, (obviously) I have to (figure out how to) write a regular expression” before I'll be able to “get that.”

    And I'm reaching over and hitting the Pause button and saying... “oh, really?” I'll bet that there's a very good CPAN-module already out there which will give you the answer that you want. I'll wager that in fact you don't have to tackle regular-expressions in order to get the result you want, because somebody out there has already done it and has done it very well.

    Dictum Ne Agas — “Do Not Do A Thing Already Done.”

      For the "this or that part", they need a different module which can extract the parts like host, path, query string, port etc. etc.


      Nobody says perl looks like line-noise any more
      kids today don't know what line-noise IS ...
Re^2: Regex for extracting a domain name from a string.
by jnbek (Scribe) on Feb 28, 2008 at 05:37 UTC

    Thank you for pointing me to the modules, I think those will work great. Between URI::Find and URI::Find::Schemeless I 'should' be able to get done what I need. I'll let you know my results.

    Thanks,

    jnbek

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found