slaclnx has asked for the wisdom of the Perl Monks concerning the following question:
I apologize I am a novice at regexp and am struggling trying to figure this out. I'm trying to parse a string that is either in one of the two following forms:
1) hostname.company.com:80//directory/...
or
2) hostname.company.com:80//
I am looking to get the hostname and the directory if it exists with a single regexp if possible (for minimalizing code). I currently have the following for the first scenario:
/\:\/\/(.*?)\:\d{2,4}\/\/(.*?)\//
And this works for the second:
/\:\/\/(.*?)\:\d{2,4}\/\//
I was wondering if there was a way construct a single regexp that would work for both? Any suggestions?
Thanks
slaclnx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can you do an OR with a REGEXP
by ikegami (Patriarch) on May 21, 2009 at 19:45 UTC | |
|
Re: Can you do an OR with a REGEXP
by zwon (Abbot) on May 21, 2009 at 19:05 UTC | |
by slaclnx (Initiate) on May 22, 2009 at 14:51 UTC | |
|
Re: Can you do an OR with a REGEXP
by kennethk (Abbot) on May 21, 2009 at 19:16 UTC |