[Israel.pm] match & expression Q.

Jason Elbaum Jason.Elbaum at freescale.com
Sun Jul 18 03:17:59 PDT 2004


Yehuda,

I don't know exactly what you're trying to do, but I should warn you 
that your question is not as simple as you might think. (Certainly not 
for beginners!)


> in your answer $var[0]$var[1]...will have the letters 
> can i tell it to have the words like in my Q.

The expression should have been this:

@vars = $string =~ /([0-9a-z]+)/gi;

This will collect all alphanumeric strings into @vars.


BUT:

 > it should take the word until the first space.

The problem is defining what the "word" is.


1) It only works for simple upper- and lowercase English letters. If you 
have any special letters, they will break up the strings. For example:

'cafe' (with an accent on the e) will become 'caf'
'resume' (with accents on both e's) will become 'r', 'sum'
"doesn't" will become 'doesn', 't'
'Ph.D.' will become 'Ph', 'D'
'1,000-12,500' will become '1', '000', '12', '500'
'either/or' will become 'either', 'or'

There are no simple expressions that will cover all of these cases. (Any 
internationalization gurus out there disagree?)


2) Non-English text might not work at all. Many European languages have 
special letters not covered by a-z/A-Z.


Good luck!


Jason Elbaum
Freescale Semiconductor Israel



More information about the Perl mailing list