Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Sat Feb 25, 2012 12:05 am    Post subject: handle string containing single quote(') and double quote(&q
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: 1722
Location: UK

PostPosted: Sat Feb 25, 2012 12:25 am    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Sat Feb 25, 2012 12:55 am    Post subject: Reply to: handle string containing single quote(') and doubl
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: 43
Location: Germany

PostPosted: Sat Feb 25, 2012 3:09 am    Post subject:
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: 1746
Location: Bloomington, IL

PostPosted: Sat Feb 25, 2012 3:16 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Single COPY CICS TS datasets and when... Kyle Carroll CICS 2 Tue Oct 11, 2016 9:47 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts hot to get details when "EXEC CI... Andi1982 CICS 11 Tue Sep 20, 2016 5:01 pm
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us