Try changing ($mytext) = $string =~ /In:(.*)Your/; to ($mytext) = $string =~ /In:(.*?)Your/;
This is a common problem in regular expressions. Asterisks in Perl regular expressions are inherently greedy. They will match as much as possible while stil creating a match. Try doing a search on google or perlre on "perl greedy regular expressions" for more info. -----Original Message----- From: Daniel Falkenberg To: Timothy Johnson Cc: [EMAIL PROTECTED] Sent: 3/10/02 4:05 PM Subject: RE: Finding words between words... Hello all, I have some text here that I have placed in a string. I want to be able to extract words between text of my choice. For example in the string... $string = "Hello world In: crud all Your."; ($mytext) = $string =~ /In:(.*)Your/; The above works fine but how can I tell my regex to stop as soon as it finds these words. For example if in the string... $string = "Hello world In: crud all Your. hello again In: crud aagin Your at the..."; The regex above will go crazy? Any Ideas, Thx, Dan -------------------------------------------------------------------------------- This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]