14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

580 JSL Syntax Reference Appendix A<br />

Character Pattern Functions<br />

Returns<br />

A pattern.<br />

Argument<br />

string a string.<br />

Pat Succeed()<br />

Description<br />

Constructs a pattern that always succeeds, even when the matcher backs into it. It matches the null<br />

string.<br />

Returns<br />

1 when the match succeeds.<br />

Argument<br />

none<br />

Pat Tab(int)<br />

Description<br />

Constructs a pattern that matches forward to position int in the source string. It can match 0 or more<br />

characters. It fails if it would have to move backwards or beyond the end of the string.<br />

Returns<br />

A pattern.<br />

Argument<br />

int an integer that specifies a position in a string.<br />

Pat Test(expr)<br />

Description<br />

Constructs a pattern that succeeds and matches the null string if expr is not zero and fails otherwise.<br />

Returns<br />

A pattern.<br />

Argument<br />

expr An expression.<br />

Note<br />

Usually the argument is wrapped with expr() because the test needs to be made on the current value of<br />

variables set by Pat Immediate, Pat Conditional, and Pat At. Without expr, the test is based on<br />

values that were known when the pattern was constructed, which means the test always succeeds or<br />

always fails at pattern execution time, which is probably not what you want.<br />

Example<br />

nCats = 0;<br />

whichCat = 3;<br />

string = "catch a catnapping cat in a catsup factory";<br />

rc = Pat Match(string, "cat" + Pat Test(expr(nCats=nCats+1; nCats ==<br />

whichCat)), "dog");<br />

show(rc, string, nCats);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!