パターンに一致する部分文字列の位置と長さを返します。
| カテゴリ: | 文字列マッチング |
| 制限事項: | PRXPARSE関数とともに使用します。 |
| このCALLルーチンに必要なPRXPARSE関数にDBCSとの互換性がないため、DBCSおよびMBCSデータの処理にこの関数を使用しないでください。 | |
| 操作: | %SYSCALLマクロステートメントで呼び出されると、CALL PRXSUBSTRの引数から引用符が削除されます。詳細については、 CALLルーチンと%SYSCALLマクロステートメントを使用する を参照してください。 |
data _null_;
/* Use PRXPARSE to compile the Perl regular expression. */
patternID = prxparse('/world/');
/* Use PRXSUBSTR to find the position and length of the string. */
call prxsubstr(patternID, 'Hello world!', position, length);
put position= length=;
run;position=7 length=5
data _null_;
if _N_ = 1 then
do;
retain ExpressionID;
/* The i option specifies a case insensitive search. */
pattern = "/ave|avenue|dr|drive|rd|road/i";
ExpressionID = prxparse(pattern);
end;
input street $80.;
call prxsubstr(ExpressionID, street, position, length);
if position ^= 0 then
do;
match = substr(street, position, length);
put match:$QUOTE. "found in " street:$QUOTE.;
end;
datalines;
153 First Street
6789 64th Ave
4 Moritz Road
7493 Wilkes Place
;
run;"Ave" found in "6789 64th Ave" "Road" found in "4 Moritz Road"