> -----Original Message----- > From: A. Rivera [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 13, 2001 1:39 PM > To: [EMAIL PROTECTED] > Subject: regex help > > > Ok, > > I need help find the most effecient way to do this.. > > I have a variable... > $data="this is a test"; > > What is the quickest way to get $data to equal just the first > two words of > the original variable....
It depends on how you define a "word". If you mean any sequence of non-whitespace, something like this should work: ($data) = $data =~ /(\S+\s+\S+)/; \S+ matches first "word" \s+ matches whitespace between words \S+ matches second "word" -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]