2010 Oct 04 10:36 AM
Hi,
I have a string in the below format.
<?xml version="1.0" encoding="UTF-8"?>#<Data>##><Row>#####<Entry>Test1</Entry>#####<Entry>Dtest2</Entry>#####<Entry>Test3</Entry>#####<Entry>-</Entry>#####<Entry>-</Entry>#####<.........so on
i wanted this string without '#' as below:
<?xml version="1.0" encoding="UTF-8"?><Data>><Row><Entry>Test1</Entry><Entry>Dtest2</Entry><Entry>Test3</Entry><Entry>-</Entry><Entry>-</Entry><.........so on
I tried using REPLACE ALL OCCURENCES REGEX '[[:punct:]]' for string with ''.
This is removing even the '<' , '>', '/' , etc...[Its resulting only the alphabets and numbers.
Can some one please provide a feasible solution.
Regards,
Rajkamal
2010 Oct 04 10:45 AM
REPLACE ALL OCCURENCES OF REGEX '\Q#\E' IN gv_string WITH ''.
Hi,
I have a string in the below format.
<?xml version="1.0" encoding="UTF-8"?>#<Data>##><Row>#####<Entry>Test1</Entry>#####<Entry>Dtest2</Entry>#####<Entry>Test3</Entry>#####<Entry>-</Entry>#####<Entry>-</Entry>#####<.........so on
i wanted this string without '#' as below:
<?xml version="1.0" encoding="UTF-8"?><Data>><Row><Entry>Test1</Entry><Entry>Dtest2</Entry><Entry>Test3</Entry><Entry>-</Entry><Entry>-</Entry><.........so on
I tried using REPLACE ALL OCCURENCES REGEX '[[:punct:]]' for string with ''.
This is removing even the '<' , '>', '/' , etc...[Its resulting only the alphabets and numbers.
Can some one please provide a feasible solution.
Regards,
Rajkamal
2010 Oct 04 10:45 AM
REPLACE ALL OCCURENCES OF REGEX '\Q#\E' IN gv_string WITH ''.
2010 Oct 04 10:52 AM
Hi,Thanks for the response.
The above code did not work
Nothing changes.
Regards,
Rajkamal
2010 Oct 04 11:02 AM
2010 Oct 04 11:15 AM
>
> Hi,Thanks for the response.
>
> The above code did not work
>
> Nothing changes.
>
> Regards,
> Rajkamal
Already had a feeling this would be your reply.
Do as Matt requested.
2010 Oct 04 11:20 AM
2010 Oct 04 12:16 PM
That's good. So it really is a '#'.
You could use the non-regex REPLACE ALL OCCURENCES OF '#' IN my_string WITH space. And then use CONDENSE NO-GAPS.
Regex for me has always been trial and error, using the online tutorial and online test tools, which you can find with google.
2010 Oct 04 12:28 PM
2010 Oct 04 12:36 PM
Oh no! Even this is not working for me!
I would like to explain my scenario a bit brief .
I am calling a URL using web service. The methods called for this are : CALL METHOD http_client->send , CALL METHOD http_client->receive
Then storing the received data as: result = http_client->response->get_cdata( ). [This is resulting in as XML with '#' as mentioned above].
Regards,
Rajkamal
2010 Oct 04 12:38 PM
Is the result an internal table? A single variable? What's the type definition?
2010 Oct 04 12:40 PM
2010 Oct 04 12:46 PM
data: gv_string type string.
gv_string = '<?xml version="1.0" encoding="UTF-8"?>#<Data>##><Row>#####<Entry>Test1</Entry>#####<Entry>Dtest2</Entry>#####<Entry>Test3</Entry>#####<Entry>-</Entry>#####<Entry>-</Entry>#####<.........>'.
write: / gv_string.
REPLACE ALL OCCURENCES OF REGEX '\Q#\E' IN gv_string WITH ''.
write: / gv_string.My example that worked.
2010 Oct 04 12:56 PM
Yes, the above code worked for me as well. Is it like the hard-coded values accept the statement REPLACE ALL OCCURENCES OF REGEX '\Q#\E' IN gv_string WITH '', but not the string which we get dynamically?
2010 Oct 04 1:36 PM
Hi Matt/Maen,
The issue is resolved. The string with #### is not exactly'#' value, but they are actually representing horizontal tab and new line.
To overcome this, i used :
REPLACE ALL OCCURRENCES OF SUBSTRING cl_abap_char_utilities=>horizontal_tab IN result WITH ''.
REPLACE ALL OCCURRENCES OF SUBSTRING cl_abap_char_utilities=>newline IN result WITH ''.
Thanks for your time.
Regards,
Rajkamal
2010 Oct 04 2:19 PM
So the hex value of the # in your input string wasn't x0023. Which is what we suspected in the first place!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |