|
|||||
|
|||||
Related Concepts | |||||
pattern |
null |
Syntax
null pattern
You can use the pattern modifier null
to change OmniMark's default behavior for consecutive zero-length matches.
By default, OmniMark does not allow two consecutive matches that match zero characters. This prevents patterns from going into infinite loops in which the same pattern matches zero characters over and over again without progressing through the data.
Any pattern that is preceded by the null
modifier is allowed to match zero characters even if the the previous match was zero-length:
find null digit*
The above pattern will match and consume digits if it finds them. If it does not find digits, it will match anyway because matching nothing is allowed by the "zero-or-more" occurrence indicator (*
). Because of the null
modifier, it will go on matching zero characters without restriction.
If you use null
in a pattern, you should make sure that the code that runs when the rule fires makes some state change that will eventually result in the rule not being fired. If you do not do so, your program will go into an infinite loop.
Related Concepts Pattern matching |
Copyright © Stilo International plc, 1988-2008.