Trace (Regex property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
 
Line 1: Line 1:
{{Template:Regex:Trace subtitle}}
{{Template:Regex:Trace subtitle}}


This page is [[under construction]].
A ReadWrite property indicating whether or not regular expression processing is to be traced for the <var>Regex</var> object.
==Syntax==
==Syntax==
{{Template:Regex:Trace syntax}}
{{Template:Regex:Trace syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%boolean</th><td><var>Boolean</var> value</td></tr>
<tr><th>%currentBoolean</th><td>If the value is being retrieved (not set), the current <var>Boolean</var> value of the trace flag.</td></tr>
<tr><th>regex</th>
<tr><th>regex</th>
<td><var>Regex</var> object</td></tr>
<td>The <var>Regex</var> object.</td></tr>
<tr><th>newBoolean</th><td>If the value is being set (not retrieved), the new <var>Boolean</var> value of the trace flag.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<li>This adds or removes the <code>T</code> option from the <var>Regex</var> object. The new setting is reflected in any subsequent request for the [[Options (Regex property)|Options property]].</li>
<li>For more information about <var>Regex</var> options see [[Regex_processing#Common_regex_options|Common regex options]].</li>
</ul>
==Examples==
==Examples==
The following does the same regular expression match first without, and then with tracing set.
<p class="code">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                                                           
</p>
The above displays:
<p class="code">%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?")=             
&#x2a;**  M204.2982: ===> Match starting regex scan at string position 0
&#x2a;**  M204.2984: +A0 (ANCH), pos: 1, string pos: 11               
&#x2a;**  M204.2984: >A1 (STR), pos: 1, string pos: 11                 
&#x2a;**  M204.2984: +A1 (STR), pos: 1, string pos: 13                 
&#x2a;**  M204.2984: >A2 (DOT*), pos: 3, string pos: 13               
&#x2a;**  M204.2984: +A2 (DOT*), pos: 3, string pos: 13               
&#x2a;**  M204.2984: >A3 (STR), pos: 6, string pos: 13                 
&#x2a;**  M204.2984: -A3 (STR), pos: 6, string pos: 13                 
&#x2a;**  M204.2984: <A2 (DOT*), pos: 3, string pos: 13               
&#x2a;**  M204.2984: +A2 (DOT*), pos: 3, string pos: 14               
&#x2a;**  M204.2984: >A3 (STR), pos: 6, string pos: 14                 
&#x2a;**  M204.2984: -A3 (STR), pos: 6, string pos: 14                 
&#x2a;**  M204.2984: <A2 (DOT*), pos: 3, string pos: 14               
&#x2a;**  M204.2984: +A2 (DOT*), pos: 3, string pos: 15               
&#x2a;**  M204.2984: >A3 (STR), pos: 6, string pos: 15                 
&#x2a;**  M204.2984: +A3 (STR), pos: 6, string pos: 17                 
&#x2a;**  M204.2984: >A0 (ANCH), pos: 1, string pos: 17               
17                                                               
</p>
==See also==
==See also==
{{Template:Regex:Trace footer}}
{{Template:Regex:Trace footer}}
[[Category:Regular expression processing]]

Latest revision as of 21:36, 24 March 2022

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