Hello Gerd,

Historians believe that Sun, 28 Jan 2001 at 11:20 GMT +0100 was when,
Gerd Ewald [GE] typed the following:

GE>>> PMFJI,
<snip>
GE> Pardon Me For Jumping In

Ah.  Thanks.

>>>> "(?is)
<snip>
GE> Thanks: case insensitive and dot means any character incl. newline.

Right.

<snip>
GE> Ah, example: (\d*?)[a-z]  does this mean:

GE> "find none [...] digit if followed by a lowercase letter and store digit
GE> in subpatt or, if it is the only way the pattern matches, take as many
GE> digits as necessary followed by a lowercase letter to store the digits in
GE> subpatt"?

Note the editing, but yes, that's the idea.

GE> I'm not sure that I understood that because: if there is 1 digit and a
GE> letter, the digit is stored; two digits and a letter dito, three digits
GE> dito...... That is the same as the metacharacter * or {0,}

Well, consider this:  Suppose you have the string "1234567a", and you
apply your example.  Then the minimum number of digits before the "a"
is zero.  So you'd get an empty subpattern.  Now if you remove the "?"
from your example, you'd match the maximum number of digits, and so
the subpattern would hold "1234567"

<snip>
GE> can you give an example for that?

Maybe this variation from the help file one will help.  Suppose you
have two sentences on a single line:

This is one sentence. This is another sentence.

Now if you use the pattern "^.*\.", you're saying, start at the
beginning of the line and match any number of any characters
terminated by a period.  Now this expression will match both
sentences, even though you only wanted the first sentence.  Change the
pattern to "^.*?\." and you get only the first sentence.

<snip>
GE> Yes, options. But I found another occurrence of the ? in so-called
GE> Assertions. I understood the help file there.

Right.  I wasn't making the distinction between the various "(?"
meanings.  But if we do that, the ? occurs in conditionals too.

<snip>
GE> Although I understood the example with the spring in a box I still do not
GE> see how this works practical (see above).

Is it any clearer now? (I'll keep asking until you stop asking good
questions.  Keep them coming.)

<snip>

-- 
Thanks for writing,
 Januk Aggarwal

 Using The Bat! 1.49c under Windows 98 4.10 Build 2222  A

 I have an imaginary friend who refuses to play with me.

-- 
______________________________________________________
Archives   : <http://tbtech.thebat.dutaint.com>
Moderators : <mailto:[EMAIL PROTECTED]>
Unsubscribe: <mailto:[EMAIL PROTECTED]>

You are subscribed as : [email protected]


Reply via email to