Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regular Expression to find Word Prefixes

by vladdrak (Monk)
on May 19, 2002 at 23:15 UTC ( [id://167738]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression to find Word Prefixes

Well, if you can assume that the data will always follow the pattern you presented, then you can split on a space:
my @words=( "12 chem1", "1/2 chem2", "(N+1) chem3", "2M chem4", "N chem5" ); # given an array of words, returns an # array of corresponding prefixes sub get_prefixes { map { (split)[0] } @_; } print join(",",get_prefixes(@words));
-Vlad

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found