|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
![Reply to topic](templates/DAJ_Glass/images/lang_english/reply.gif) |
|
How to identify a special character in ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
IIBLearnerVSK |
Posted: Thu Jan 05, 2017 8:20 am Post subject: How to identify a special character in ESQL |
|
|
![](images/avatars/gallery/Southpark/avatar13.gif) Newbie
Joined: 17 Apr 2015 Posts: 3
|
Hello All,
I have a requirement like below:
I have to check a string for special characters and allow that string only when a _ (underscore) is present, among all the other special characters.
If any special character exists in that string other than _ , I should throw an exception.
Could any one please help me how to look for special characters in a string?
I thought of extracting each character and compare it with a list of special characters, but it doesn't seem right. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
Vitor |
Posted: Thu Jan 05, 2017 8:29 am Post subject: Re: How to identify a special character in ESQL |
|
|
![](images/avatars/905340816499abc1cdfb07.jpg) Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
IIBLearnerVSK wrote: |
Could any one please help me how to look for special characters in a string? |
Use the ESQL TRANSLATE function to strip out alphanumber ("normal") characters.
If no characters remain, you're missing the _ that you claim you want
If only _ remains, awesome.
If there's anything other than a _ (and you can use TRANSLATE again to strip that out) you apparently have a problem.
If you're using Java, you can probably do something clever with a regular expression. Maybe. _________________ Honesty is the best policy.
Insanity is the best defence.
Last edited by Vitor on Thu Jan 05, 2017 8:30 am; edited 1 time in total |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
adubya |
Posted: Thu Jan 05, 2017 8:30 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Not 100% sure I follow.
But if you're looking to see if any of a set of characters is present in a string then you could use the ESQL TRANSLATE function to replace the special characters (you can specify them all in the "SearchStringExpression" argument to TRANSLATE) with an empty character i.e. delete the special characters. Then compare the length of the result string with the length of the original input string. If they are different then a special character was present in your input string and you can throw an exception.
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ak05261_.htm _________________ Independent Middleware Consultant
andy@knownentity.com |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
IIBLearnerVSK |
Posted: Wed Jan 11, 2017 3:05 am Post subject: |
|
|
![](images/avatars/gallery/Southpark/avatar13.gif) Newbie
Joined: 17 Apr 2015 Posts: 3
|
Thanks Vitor and Adubya.
It worked fine with TRANSLATE function. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
|
|
![Reply to topic](templates/DAJ_Glass/images/lang_english/reply.gif) |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|