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 » Remove special characters from a string

Post new topic  Reply to topic Goto page 1, 2  Next
 Remove special characters from a string « View previous topic :: View next topic » 
Author Message
Luca81
PostPosted: Thu Jun 14, 2007 11:44 pm    Post subject: Remove special characters from a string Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

Hi all

I'm using WBI v 5 CSD06.
In my ESQL module I have a string with special chars (<,>,",& ecc ecc)
I'd like "clean" this string. I want only 0..9, A...Z, a...z characters.
I can replace specials characters with a blank or with ;amps ecc ecc.
Do I have to create a self defined function or can I use some native ESQL functions?
Can u help me?
Thx u
Luca


Last edited by Luca81 on Mon Jun 18, 2007 7:13 am; edited 1 time in total
Back to top
View user's profile Send private message
jbanoop
PostPosted: Fri Jun 15, 2007 6:38 am    Post subject: Reply with quote

Chevalier

Joined: 17 Sep 2005
Posts: 401
Location: SC

REPLACE function
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ak05241_.htm
Back to top
View user's profile Send private message Yahoo Messenger
Luca81
PostPosted: Fri Jun 15, 2007 6:45 am    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

jbanoop wrote:
REPLACE function
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ak05241_.htm


Yes ok...
But I can't make a REPLACE for all specials characters...

Luca
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Fri Jun 15, 2007 6:55 am    Post subject: Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

Luca81 wrote:
jbanoop wrote:
REPLACE function
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ak05241_.htm


Yes ok...
But I can't make a REPLACE for all specials characters...

Luca


No.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
jbanoop
PostPosted: Fri Jun 15, 2007 6:56 am    Post subject: Reply with quote

Chevalier

Joined: 17 Sep 2005
Posts: 401
Location: SC

that you will have to write functions of your own.. your special characters may be part of regular characters for another requirement.
Anyways it is not a hard task.
Back to top
View user's profile Send private message Yahoo Messenger
marcin.kasinski
PostPosted: Fri Jun 15, 2007 7:03 am    Post subject: Re: Remove spacial chars from a string Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

You can use loop to check every chars in your string if it is between 0..9 and between A...Z .

If it is do nothing , if it is not use REPLACE function.

How to check if it is between ?

Every character has own char code. You can check if it is less then ... or higher than ...
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
Luca81
PostPosted: Fri Jun 15, 2007 7:18 am    Post subject: Re: Remove spacial chars from a string Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

marcin.kasinski wrote:
You can use loop to check every chars in your string if it is between 0..9 and between A...Z .

If it is do nothing , if it is not use REPLACE function.

How to check if it is between ?

Every character has own char code. You can check if it is less then ... or higher than ...


OK thx I will try.
Luca
Back to top
View user's profile Send private message
kimbert
PostPosted: Sun Jun 17, 2007 1:57 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I'd like "clean" this string. I want only 0..9, A...Z, a...z characters.
I can replace specials characters with a blank or with ;amps ecc ecc.
Why do you need to do this? Are you by any chance trying to make your string XML-compatible?
Back to top
View user's profile Send private message
Luca81
PostPosted: Sun Jun 17, 2007 11:32 pm    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

kimbert wrote:
Quote:
I'd like "clean" this string. I want only 0..9, A...Z, a...z characters.
I can replace specials characters with a blank or with ;amps ecc ecc.
Why do you need to do this? Are you by any chance trying to make your string XML-compatible?


Yes...
In my XML I have to insert a String... But If I have '<' '>' '&' ecc ecc I have parser exception...
So I have to 'clean' the String...
marcin.kasinski wrote:
Every character has own char code. You can check if it is less then ... or higher than ...
How can I find the code?
Can you help me writing code?
Thx u
Luca
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Sun Jun 17, 2007 11:38 pm    Post subject: Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

Luca81 wrote:

...
In my XML I have to insert a String... But If I have '<' '>' '&' ecc ecc I have parser exception...
So i have to 'clan' the String...


Why you don't you escape this data during sending it from your application ?

< = &lt;
> = &gt;
... = ...

You can also use CDATA XML tag to put non XML data into XML.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
Luca81
PostPosted: Sun Jun 17, 2007 11:44 pm    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

marcin.kasinski wrote:
Luca81 wrote:

...
In my XML I have to insert a String... But If I have '<' '>' '&' ecc ecc I have parser exception...
So i have to 'clan' the String...


Why you don't you escape this data during sending it from your application ?

< = &lt;
> = &gt;
... = ...

You can also use CDATA XML tag to put non XML data into XML.


I can't use CDATA...
The string has a lot of special characters... é.ç,° ecc ecc
I want only 0...9, a....z, A....Z
Back to top
View user's profile Send private message
Luca81
PostPosted: Mon Jun 18, 2007 12:02 am    Post subject: Re: Remove spacial chars from a string Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

marcin.kasinski wrote:


Every character has own char code. You can check if it is less then ... or higher than ...


This is a good idea.. But, How find a char code? Can u help me writing code?
thx u a lot
Luca
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 18, 2007 12:49 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

If you need to put non-XML characters into an XML document then you should consider using base64 encoding. MRM XML will automatically do base64 encoding as it writes the output message. Alternatively, you could call a standard java method to encode the string and use XMLNS/XMLNSC.
Back to top
View user's profile Send private message
Luca81
PostPosted: Mon Jun 18, 2007 12:59 am    Post subject: Reply with quote

Acolyte

Joined: 01 Mar 2007
Posts: 62

kimbert wrote:
If you need to put non-XML characters into an XML document then you should consider using base64 encoding. MRM XML will automatically do base64 encoding as it writes the output message. Alternatively, you could call a standard java method to encode the string and use XMLNS/XMLNSC.


I can't use Java code...
I have ONLY to clean a string... Remove all chararcters except 0..9, a..z and A...Z
Is it possible??
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jun 18, 2007 2:50 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Of course it's possible. But is it a good idea? I don't recall other users wanting to do this. So are you sure that removing these characters using ESQL is
a) necessary
b) the best solution

Quote:
But If I have '<' '>' '&' ecc ecc I have parser exception

All the WMB XML parsers ( XML / XMLNS / XMLNSC / MRM ) will automatically escape these characters and many others when they write the output message. What exactly is this string, and what are you trying to do with it?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Remove special characters from a string
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.