Post Reply 
Addings/modifications to help files
Jul. 20, 2009, 03:35 AM
Post: #16
RE: Addings/modifications to help files
Quote:10a Loops -- Limiting expression scopes.
You can use "+" loops to isolate subexpressions, removing their
capatibility to look ahead.

No, "+" doesn't look ahead, it just repeats the preceding expression blindly. The help file has below words:

Quote:An important point to make about + is that it's a "blind" run. This means it repeats at long as the condition it's testing is true regardless of anything the follows it!

regardless of anything the follows it means it doesn't look ahead. BTW, the words might should be "regardless of anything that follows it".

Quote:Example:
Say we want to match <foo ... >, but only if the following tag isn't </foo >

<foo*>(^*</foo >)
... wouldn't work, because "*>" doesn't stop at the first match but is looking
ahead.

<foo[^>]+>(^[^<]+</foo >)
... would work, but [^...] forces inspection of each character.

<foo(*>)+{1}(^(*<)+{1}/foo >)
... does what we want, quickly. "*>", "*<" are not looking ahead anymore.

I think "*" is equal to "?++" in prox language while the help file has:

Quote:A double-plus acts much like the single "+" plus except it also pays attention to what comes afterwards (it can "see" so to speak).

So, The "*" itself looks ahead.

To match a string until meet a ">", "[^>]+>" is faster than "*>" because "+" just blindly repeat the "[^>]" while "*" has to check after each character match if it is followed by a ">".

Quote:10b Avoiding superfluous tests in OR conditions.
10c However, +/++ loops remove the uniqueness of the string under test, even if followed by {1,*}.

I don't understand what the examples are trying to show. A more detailed example might help. Smile!
Add Thank You Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Addings/modifications to help files - whenever - Jul. 20, 2009 03:35 AM

Forum Jump: