Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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


Comment on Re: First word
Select or Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-08-31 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (358 votes), past polls