/* cody.ex1a */ /* from R. Cody "An Introduction to Perl Regular */ /* Expressions in SAS 9," */ /* http://www2.sas.com/proceedings/sugi29/265-29.pdf */ ***Primary functions: PRXPARSE, PRXMATCH; DATA _NULL_; TITLE "Perl Regular Expression Tutorial – Program 1"; IF _N_ = 1 THEN PATTERN_NUM = PRXPARSE("/ cat /"); * add spaces ; *Exact match for the letters 'cat' anywhere in the string; RETAIN PATTERN_NUM; INPUT STRING $30.; POSITION = PRXMATCH(PATTERN_NUM,STRING); FILE PRINT; PUT PATTERN_NUM= STRING= POSITION=; DATALINES; There is a cat in this line. Does not match CAT cat in the beginning At the end, a cat cat ;