CALL PRXDEBUG Routine

Enables Perl regular expressions in a DATA step to send debugging output to the SAS log.

Category: Character String Matching
Restriction: Use with the CALL PRXCHANGE, CALL PRXFREE, CALL PRXNEXT, CALL PRXPOSN, CALL PRXSUBSTR, PRXPARSE, PRXPAREN, and PRXMATCH functions and CALL routines. The PRXPARSE function is not DBCS compatible.

Syntax

CALL PRXDEBUG (on-off);

Required Argument

on-off

specifies a numeric constant, variable, or expression. If the value of on-off is positive and non-zero, then debugging is turned on. If the value of on-off is zero, then debugging is turned off.

Details

The CALL PRXDEBUG routine provides information about how a Perl regular expression is compiled, and about which steps are taken when a pattern is matched to a character value.
You can turn debugging on and off multiple times in your program if you want to see debugging output for particular Perl regular expression function calls.
For more information about pattern matching, see Pattern Matching Using Perl Regular Expressions (PRX).

Comparisons

The Perl regular expression (PRX) functions and CALL routines work together to manipulate strings that match patterns. To see a list and short description of these functions and CALL routines, see the Character String Matching category in SAS Functions and CALL Routines by Category.

Example

The following example produces debugging output.
data _null_;
      /* Turn the debugging option on. */
   call prxdebug(1);
   putlog 'PRXPARSE: ';
   re = prxparse('/[bc]d(ef*g)+h[ij]k$/');
   putlog 'PRXMATCH: ';
   pos = prxmatch(re, 'abcdefg_gh_');
      /* Turn the debugging option off. */
   call prxdebug(0);
run;
The following lines are written to the SAS log.
SAS Log Results from CALL PRXDEBUG
PRXPARSE: 
Compiling REx '[bc]d(ef*g)+h[ij]k$'  1
size 41 first at 1  2
rarest char g at 0  5
rarest char d at 0
   1: ANYOF[bc](10)  3
  10: EXACT <d>(12)
  12: CURLYX[0] {1,32767}(26)
  14:   OPEN1(16)
  16:     EXACT <e>(18)
  18:     STAR(21)
  19:       EXACT <f>(0)
  21:     EXACT <g>(23)
  23:   CLOSE1(25)
  25:   WHILEM[1/1](0)
  26: NOTHING(27)
  27: EXACT <h>(29)
  29: ANYOF[ij](38)
  38: EXACT <k>(40)
  40: EOL(41)
  41: END(0)
anchored 'de' at 1 floating 'gh' at 3..2147483647 (checking floating)  4 
stclass 'ANYOF[bc]' minlen 7  6 
PRXMATCH: 
Guessing start of match, REx '[bc]d(ef*g)+h[ij]k$' against 'abcdefg_gh_'...
Did not find floating substr 'gh'...
Match rejected by optimizer
The following items correspond to the lines that are numbered in the SAS log that is shown above.
1 This line shows the precompiled form of the Perl regular expression.
2 Size specifies a value in arbitrary units of the compiled form of the Perl regular expression. 41 is the label ID of the first node that performs a match.
3 This line begins a list of program nodes in compiled form for regular expressions.
4 These two lines provide optimizer information. In the example above, the optimizer found that the match should contain the substring de at offset 1, and the substring gh at an offset between 3 and infinity. To rule out a pattern match quickly, Perl checks substring gh before it checks substring de.
The optimizer might use the information that the match begins at the first ID (line 2), with a character class (line 5), and cannot be shorter than seven characters (line 6).