Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex to get everything before first /

by wind (Priest)
on Jun 06, 2011 at 19:39 UTC ( #908356=note: print w/replies, xml ) Need Help??


in reply to Regex to get everything before first /

One final addition to toolic and davido's posts:

You might as well make it match {0,} instead of {1,} so that strings that start with / will equal the empty string instead of undef.

This way you can avoid "Use of uninitialized value in concatenation (.)" warnings.

use warnings; use strict; my $thing = 'foo/bar/goo'; my ($stuff) = $thing =~ m{^([^/]*)}; print "$stuff\n"; __END__ foo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2021-01-27 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?