Search notes:

SAS regular expressions: get value captured with parentheses

data _null_;

   numbers = 'foo bar baz 42';

   regexpId = prxparse('/(\w+) (\w+) (\w+) (\w+)/');

   pos = prxmatch(regexpId, numbers);

   if pos > 0 then do;

      do paranNo = 1 to 4;

         call prxposn(regexpId, paranNo, txtStart, txtEnd);
         txtMatched = substr(numbers, txtStart, txtEnd);
         put "paranthesis " paranNo ": " txtMatched; 
      end;
   end;

run;
/*
paranthesis 1 : foo
paranthesis 2 : bar
paranthesis 3 : baz
paranthesis 4 : 42
*/
Github repository about-SAS, path: /programming/regular-expressions/paranthesis-value.sas

See also

SAS: regular expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Companie...', 1758206760, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/regular-expressions/paranthesis-value(62): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78