Author |
Message
|
Luca81 |
Posted: Thu Jun 14, 2007 11:44 pm Post subject: Remove special characters from a string |
|
|
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 |
|
 |
jbanoop |
Posted: Fri Jun 15, 2007 6:38 am Post subject: |
|
|
Chevalier
Joined: 17 Sep 2005 Posts: 401 Location: SC
|
|
Back to top |
|
 |
Luca81 |
Posted: Fri Jun 15, 2007 6:45 am Post subject: |
|
|
Acolyte
Joined: 01 Mar 2007 Posts: 62
|
Yes ok...
But I can't make a REPLACE for all specials characters...
Luca |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Fri Jun 15, 2007 6:55 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Luca81 wrote: |
Yes ok...
But I can't make a REPLACE for all specials characters...
Luca |
No. _________________ Marcin |
|
Back to top |
|
 |
jbanoop |
Posted: Fri Jun 15, 2007 6:56 am Post subject: |
|
|
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 |
|
 |
marcin.kasinski |
Posted: Fri Jun 15, 2007 7:03 am Post subject: Re: Remove spacial chars from a string |
|
|
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 |
|
 |
Luca81 |
Posted: Fri Jun 15, 2007 7:18 am Post subject: Re: Remove spacial chars from a string |
|
|
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 |
|
 |
kimbert |
Posted: Sun Jun 17, 2007 1:57 pm Post subject: |
|
|
 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 |
|
 |
Luca81 |
Posted: Sun Jun 17, 2007 11:32 pm Post subject: |
|
|
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 |
|
 |
marcin.kasinski |
Posted: Sun Jun 17, 2007 11:38 pm Post subject: |
|
|
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 ?
< = <
> = >
... = ...
You can also use CDATA XML tag to put non XML data into XML. _________________ Marcin |
|
Back to top |
|
 |
Luca81 |
Posted: Sun Jun 17, 2007 11:44 pm Post subject: |
|
|
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 ?
< = <
> = >
... = ...
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 |
|
 |
Luca81 |
Posted: Mon Jun 18, 2007 12:02 am Post subject: Re: Remove spacial chars from a string |
|
|
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 |
|
 |
kimbert |
Posted: Mon Jun 18, 2007 12:49 am Post subject: |
|
|
 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 |
|
 |
Luca81 |
Posted: Mon Jun 18, 2007 12:59 am Post subject: |
|
|
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 |
|
 |
kimbert |
Posted: Mon Jun 18, 2007 2:50 am Post subject: |
|
|
 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 |
|
 |
|