IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

handle string containing single quote(') and double quote(&q


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 46
Location: Germany

PostPosted: Sat Feb 25, 2012 12:05 am
Reply with quote

Hi,

I have to handle a string, which may contain single quote ' and double quote " (shift 2), it also may contain two singe quotes ('') or 2 double quotes ("").

Maybe I'll take the risk and translate a ' to x'EF' and translate it back afterwards.

My question: Is there a smarter way to handle it?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Feb 25, 2012 12:25 am
Reply with quote

Totally depends on what processing you are doing on the string.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Feb 25, 2012 12:55 am
Reply with quote

Quote:
Maybe I'll take the risk and translate a ' to x'EF' and translate it back afterwards.


while writing a JCL analyzer as an EDIT macro I was I was faced with the same problem when dealing with JCL statements containing it ,
both for the ' and the&


since I was not on research/investigate mood
I took the lazy road of translating them to x'FF' and x'FE'
never faced any issues.

but using rexx You have the also the advantage that strings can be delimited using "

to keep it short You can safely use the translate trick
Back to top
View user's profile Send private message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 46
Location: Germany

PostPosted: Sat Feb 25, 2012 3:09 am
Reply with quote

Thanks Enrico,

I'll do it, even it it not so sure as your example with JCL.

My Input is a COBOL Program source code und hex values make more sense here as in a JCL.

@Nic: Have you any hint, knowing now it's cobol source?

Mike
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Feb 25, 2012 3:16 am
Reply with quote

You could also, as Dr. Sorichetti intimates, take advantage of the fact that both single and double quotes are allowed as delimiters in Rexx.

Thus, suppose you are searching for the token "'FOOBAR'" (i.e., delimited by single quotes). A possible code fragment might be:
Code:
single_quote = "'"
schwing = single_quote || 'FOOBAR' || single_quote

if (pos(schwing,string)=0) then call home
else call girl
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Feb 25, 2012 3:16 am
Reply with quote

regardless of the source type,
dealing with single and double quotes in rexx can be a challange
as they almost require an escape code to deal with.
extra KEYWORDS are required to qualify the data value.
because you are dealing with data values in the rexx program.

most people i know use Enrico's method
to deal with single and double quotes
when they are part of the character text being manipulated.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
Search our Forums:

Back to Top