Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Regular Expression to find Word Prefixes

by vladdrak (Monk)
on May 19, 2002 at 23:15 UTC ( #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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2023-02-06 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?