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

Re: First word

by haoess (Curate)
on Apr 24, 2008 at 08:56 UTC ( #682585=note: print w/replies, xml ) Need Help??


in reply to First word

$ perl -wle 'print shift =~ /^(\w+)\b/' "That's my sentence." That

As you can see, \w matches a word character, and \b marks the end of the first word (since we're matching the beginning aka ^ of the string).

More information at perlre.

-- Frank

Replies are listed 'Best First'.
Re^2: First word
by grizzley (Chaplain) on Apr 24, 2008 at 09:49 UTC
    You don't need \b because \w+ is greedy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://682585]
help
Chatterbox?
erix is always in favour of code-revolutions
[Lady_Aleena]: Well, right now, I"m looking at modules where I put randomness that aren't in my RolePlaying/Random dir, like RolePlaying:: Character:: Alignment that is mostly about random_alignment than expand_alignment.
[erix]: cute
[Lady_Aleena]: So, I'm thinking about splitting it between the two different things.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-05-27 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?