Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^3: Perl RegEx (url explode)

by Perlbotics (Chancellor)
on Nov 01, 2012 at 23:28 UTC ( #1001885=note: print w/replies, xml ) Need Help??

in reply to Re^2: Perl RegEx (url explode)
in thread Perl RegEx (url explode)

Try to match a character class that does not contain ':' (i.e. [^:]):

use strict; use warnings; for my $uri( qw( ) ) { print "in ($uri):\n"; my (@spl) = $uri =~ m|(http(?:s?))? (?:(?:://)? (w{0,3})\.{0,1})? ((.*)(?:\.)([^:/]*)) # match if it is not a ":" (?::(\d{0,10}))? |x; print 'out: ', join(', ', map { defined $_ ? $_ : '-' } @spl), "\n\ +n"; } __DATA__ in ( out: https, www,, example, de, - in ( out: http, www,, example, de, - in ( out: https, ,, example, de, - in ( out: http, ,, example, de, - in ( out: -, www,, example, de, - in ( out: -, ,, example, de, 123 in ( out: http, www,, example, de, 445 in ( out: http, www,, example, de, - in ( out: http, www,, example, de, 445
Update: Added '/' to character class and example '#foo'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001885]
[Corion]: ambrus: I guess my profs were more oldskool that way and didn't farm out stuff except tutoring the exercises to students, but my profs were mostly theoretical mathematicians, not applied
[ambrus]: As in, high-ranking people have to coordinate a department, decide about tricky individual non-professional questions that come up, and submit proposals for grants. Secretaries are useful for helping in that.
[ambrus]: Corion: oh sure, a professor can still choose to do anything themselves if they have time and want to get it right.
[ambrus]: And most of them do write articles themselves at least.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-09-26 10:46 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.