? means minimal matching not maximal, so without the question mark it would match up to the second closing paren in the following line.
( test data ) ( more test data ) which is not what you want, it would match up to the last closing paren in the data you gave it, forgetting about newlines, with the question mark it matches up to the first, which is what you want (I assume). no ? = greedy ? = on a diet Cheers, Nigel > -----Original Message----- > From: trensett [mailto:[EMAIL PROTECTED] > Sent: 17 July 2003 00:30 > To: [EMAIL PROTECTED] > Subject: Re: Regular Expression (fwd) > > > > > ---------- Forwarded message ---------- > Date: Wed, 16 Jul 2003 18:23:35 -0500 (EST) > From: trensett <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Re: Regular Expression > > > > On Wed, 16 Jul 2003, Janek Schleicher wrote: > > > Nick Diel wrote at Tue, 15 Jul 2003 11:12:18 -0600: > > > > > I am having a hard time getting a regular expression to work > the way i want > > > it to. Take the following text: bla bla bla (la la) bla bla (di da) > > > > > > I want to extract the la la to one variable and di da to > antoher variable. > > > What I have tried so far is using match variables, but so far > I am only able > > > to match either just la la or la la) bla bla (di da. > > > > It would be better if you show us not only a description of > your code, but > > your real code. > > > > The next will work: > > my @variable = $string =~ /\((.*?)\)/g; > > what's the exact implication of ".*?"? > Why wouldn't just .* in parenthesis work for this case? > > > > > > Now $variable[0] contains 'la la' and > > $variable[1] ' di da'. > > > > > > Greetings, > > Janek > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]