On May 19, 2004, at 7:21 PM, meb wrote:

My regex looks something like this:

(Save 1st 20 words):

/^(\w|\W){20}/g

^ matches only at the beginning of the string while the /g modifier tries to create a global search matching all occurrences. Matching all of what can only be in one place is pointless.


You expression matches 20 word or non-word CHARACTERS, not WORDS. Try something like:

s/^((?:\w+\W*?){20}).+$/$1.../

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to