ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to identify a special character in ESQL

Post new topic  Reply to topic
 How to identify a special character in ESQL « View previous topic :: View next topic » 
Author Message
IIBLearnerVSK
PostPosted: Thu Jan 05, 2017 8:20 am    Post subject: How to identify a special character in ESQL Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Jan 05, 2017 8:29 am    Post subject: Re: How to identify a special character in ESQL Reply with quote

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
View user's profile Send private message
adubya
PostPosted: Thu Jan 05, 2017 8:30 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
IIBLearnerVSK
PostPosted: Wed Jan 11, 2017 3:05 am    Post subject: Reply with quote

Newbie

Joined: 17 Apr 2015
Posts: 3

Thanks Vitor and Adubya.

It worked fine with TRANSLATE function.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to identify a special character in ESQL
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.