in reply to Capturing the nth word in a string
pass in a parameter to indicate which word you want. (you can eaily turn this into a function). This does not create an array and saves space, assuming the only thing you care is the nth.$_ = "ele1 ele2 ele3 ele4 ele5 ele6"; m/(\w+\s*){$ARGV[0]}/; print $1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Capturing the nth word in a string
by etcshadow (Priest) on Oct 14, 2003 at 05:04 UTC | |
by pg (Canon) on Oct 14, 2003 at 05:16 UTC | |
by etcshadow (Priest) on Oct 29, 2003 at 22:09 UTC |