14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix A JSL Syntax Reference 577<br />

Character Pattern Functions<br />

Pat Immediate(pattern, varName)<br />

Description<br />

Saves the result of the pattern match to a variable named as the second argument (varName)<br />

immediately.<br />

Returns<br />

A pattern.<br />

Arguments<br />

pattern a pattern to match against.<br />

varName the name of a variable to store the result in.<br />

Example<br />

type = "undefined";<br />

rc = Pat Match("green apples", ("red"|"green") >> type + " pears");<br />

show(rc, type);<br />

rc = 0<br />

type = "green"<br />

Even though the match failed, the immediate assignment was made.<br />

Pat Len(int)<br />

Description<br />

Constructs a pattern that matches n characters.<br />

Returns<br />

A pattern.<br />

Argument<br />

int an integer that specifies the number of characters.<br />

Pat Match(SourceText, Pattern, , , )<br />

Description<br />

Pat Match executes the Pattern against the SourceText. The pattern must be constructed first,<br />

either inline or by assigning it to a JSL variable elsewhere.<br />

Returns<br />

1 if the pattern is found, 0 otherwise.<br />

Arguments<br />

SourceText A string or string variable that contains the text to be searched.<br />

Pattern A pattern or pattern variable that contains the text to be searched for.<br />

ReplacementText Optional string that, if present, defines text to replace the pattern in the source<br />

text.<br />

ANCHOR Optional command to anchor the pattern match to the beginning of the string.<br />

FULLSCAN Optional command to force Pat Match to try all alternatives.

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

Saved successfully!

Ooh no, something went wrong!