The following should work for removing single and double quotes from a string (msg). while pos("'",msg) <> 0 setvar single_quote_pos pos("'",msg) setvar single_quote str(msg,single_quote_pos,1) setvar msg msg - single_quote endwhile while pos('"',msg) <> 0 setvar double_quote_pos pos('"',msg) setvar double_quote str(msg,double_quote_pos,1) setvar msg msg - double_quote endwhile > -----Original Message----- > From: HP-3000 Systems Discussion > [mailto:[log in to unmask]] On Behalf Of Schlosser, Robert J > Sent: Tuesday, October 14, 2003 10:27 AM > To: [log in to unmask] > Subject: Parsing stings with embedded quotes > > > I have been asked to post this to the list: > > Robert Schlosser _ MPE-CSM > Ochsner Health Plan > (504) 219-8134 > > > > I have a need to scan several lines of JCL some of which may > include either single or double quotes, and some of which may > not appear in pairs. The commonest example being the > appearance of an apostrophe. THis can be made to work > provided it is not, itself, in a string delimited by double quotes. > > The problem is that any of the standard ways of cleaning up a > line before processing it don't work! Things I've tried include: > > setvar s "Here's an example of a string with a single quote in it! " > echo !s > setvar s3 repl(!s,"'"," ") These work fine for a string with > ONLY a single instance of a single quote - we can use the > double quotes to surround it. > > However, put it in a pair of double quotes, and it doesn't > work! (Similarly for any line with both types of quotes!) > > setvar s3 '"'+"!s"+'"' > calc pos(!s3,"'") returns 0, rather than 6! > calc pos("!s3","'") has unmatched quotes > calc pos('!s3',"'") has unmatched quotes, and so on! > > > Now - granted the number of times this is likely to happen is > very small, but I have no way of knowning prior to testing, > if a line will contain single quotes or double quotes and in > what sort of combination. > > Bottom line question is - how can I safely process any > combination and sequence of single and double quotes in a > string, using the only MPE parsing functions? > > Tony Furnivall > > * To join/leave the list, search archives, change list settings, * > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html * > * To join/leave the list, search archives, change list settings, * * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *