Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Non White space function

by ikegami (Patriarch)
on Jul 17, 2020 at 21:21 UTC ( [id://11119466]=note: print w/replies, xml ) Need Help??


in reply to Non White space function

That matches "http://", followed by a space, followed by one or more "S", followed by a space. I think you want

m{http:// (\S+) }x

/x causes white space in the pattern to be ignored. \S is what matches a non-whitespace.


Note that this check if the string in $fragment contains a URL; it doesn't check if the string is a URL. For that, you'd need

m{ ^ http:// (\S+) \z }x

Of course, that not a proper check for URLs. You get false negatives (e.g HTTP://www.perlmonks.org) and false positives. Maybe you should use Regexp::Common::URI::http instead?

Update: Mentioned a specific solution. Thanks, haukex.

Update: In the description, I used /s where I meant /x. Fixed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found