Trace (Regex property)

From m204wiki
Jump to navigation Jump to search

Trace regular expression processing (Regex class)


A ReadWrite property indicating whether or not regular expression processing is to be traced for the Regex object.

Syntax

%currentBoolean = regex:Trace regex:Trace = newBoolean

Syntax terms

%currentBooleanIf the value is being retrieved (not set), the current Boolean value of the trace flag.
regex The Regex object.
newBooleanIf the value is being set (not retrieved), the new Boolean value of the trace flag.

Usage notes

  • This adds or removes the T option from the Regex object. The new setting is reflected in any subsequent request for the Options property.
  • For more information about Regex options see Common regex options.

Examples

The following does the same regular expression match first without, and then with tracing set.

b %regex is object regex %regex = new("fo.*?ar", options="i") printText {~=%regex:trace} {~=%regex:options} printText {~=%regex:match("When did 'foobar' become universal?") %regex:trace = true printText {~=%regex:trace} {~=%regex:options} printText {~=%regex:match("When did 'foobar' become universal?") end

The above displays:

%regex:trace=False %regex:options=I %regex:match("When did 'foobar' become universal?")=17 %regex:trace=True %regex:options=I %regex:match("When did 'foobar' become universal?")= *** M204.2982: ===> Match starting regex scan at string position 0 *** M204.2984: +A0 (ANCH), pos: 1, string pos: 11 *** M204.2984: >A1 (STR), pos: 1, string pos: 11 *** M204.2984: +A1 (STR), pos: 1, string pos: 13 *** M204.2984: >A2 (DOT*), pos: 3, string pos: 13 *** M204.2984: +A2 (DOT*), pos: 3, string pos: 13 *** M204.2984: >A3 (STR), pos: 6, string pos: 13 *** M204.2984: -A3 (STR), pos: 6, string pos: 13 *** M204.2984: <A2 (DOT*), pos: 3, string pos: 13 *** M204.2984: +A2 (DOT*), pos: 3, string pos: 14 *** M204.2984: >A3 (STR), pos: 6, string pos: 14 *** M204.2984: -A3 (STR), pos: 6, string pos: 14 *** M204.2984: <A2 (DOT*), pos: 3, string pos: 14 *** M204.2984: +A2 (DOT*), pos: 3, string pos: 15 *** M204.2984: >A3 (STR), pos: 6, string pos: 15 *** M204.2984: +A3 (STR), pos: 6, string pos: 17 *** M204.2984: >A0 (ANCH), pos: 1, string pos: 17 17

See also