LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 8 Nov 2007 16:04:22 -0600
Reply-To:   Yu Zhang <zhangyu05@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Yu Zhang <zhangyu05@GMAIL.COM>
Subject:   Regex solution needed.
Content-Type:   text/plain; charset=ISO-8859-1

Hi, All,

I couldn't figure out how to come up with a Regex solution for following task. Suppose i have to find evey word which doesn't end with 's' in a text file. What the Regex will be? especially when we have something like 'John's ', 'Tom's'. the regex i have tried always pick it up and match part of it, because i used the word boundary '\b'. the apostophe is a word boundary. How to overcome it?

see example below.

Note: in this contrived example, we just hav e single word each line. in reality, we want to search through the long line.

Does anyone can show me how to come up a correct Regex?

thanks!

Yu

data test; if _n_ = 1 then re = prxparse('/\b(\w*(?!=s))\b/');

retain re; infile cards truncover; input string $20.;

pos=prxmatch(re, string); if pos then match = prxposn(re, 1, string); cards; john's book ; run;


Back to: Top of message | Previous page | Main SAS-L page