<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Removing specified characters from string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914572#M1598005</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Try using REGEX, as shown in the link below from sap abapp&lt;/P&gt;&lt;P&gt;[http://help.sap.com/abapdocu_702/en/abenregex_replace.htm]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Jun 2011 04:28:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-06-17T04:28:20Z</dc:date>
    <item>
      <title>Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914570#M1598003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a little new to ABAP so bear with me.  In an ABAP class, I have a string which I currently need to remove both single and double quotes from.  I am currently solving this with two separate REPLACE statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Remove all occurrences of single and double quotes
  REPLACE ALL OCCURRENCES OF SUBSTRING '''' IN lv_all_params WITH ''.
  REPLACE ALL OCCURRENCES OF SUBSTRING '"' IN lv_all_params WITH ''.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two questions regarding this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Is there a more efficient way of solving this rather than with 2 separate REPLACE statements because if more characters also need to be removed, then I have to keep adding REPLACE statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Is there a way that if more characters are found that need to be removed, it doesn't have to result in code changes?  That is, I can configure the list of characters that need replacing outside of the code so that code remains unchanged.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 01:55:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914570#M1598003</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T01:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914571#M1598004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try &lt;STRONG&gt;TRANSLATE&lt;/STRONG&gt; statement like below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TRANSLATE lv_all_params  USING '" '' '.     " Single line can be used to replace more characters
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also check on &lt;STRONG&gt;REGULAR EXPRESSION&lt;/STRONG&gt;, &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/902ce392-dfce-2d10-4ba9-b4f777843182" target="test_blank"&gt;http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/902ce392-dfce-2d10-4ba9-b4f777843182&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 04:24:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914571#M1598004</guid>
      <dc:creator>awin_prabhu</dc:creator>
      <dc:date>2011-06-17T04:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914572#M1598005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Try using REGEX, as shown in the link below from sap abapp&lt;/P&gt;&lt;P&gt;[http://help.sap.com/abapdocu_702/en/abenregex_replace.htm]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 04:28:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914572#M1598005</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T04:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914573#M1598006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  i suggest what sap fan told do that. Use translate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please check the link also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb33a5358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb33a5358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dhina..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Dhina DMD on Jun 17, 2011 6:42 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 04:41:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914573#M1598006</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T04:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914574#M1598007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Translate text using 'pattern' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'pattern' is considered to be pairs of charecters. first charecter of each pair will be converted to second charecter of the same pair.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Converts the characters "A" to "B", "a" to "b", and vice versa. text contains "Abracadabra" after the conversion. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA text TYPE string. &lt;/P&gt;&lt;P&gt;text = `Barbcbdbarb`. &lt;/P&gt;&lt;P&gt;TRANSLATE text USING 'ABBAabba'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here pattern  'ABBAabba'  - can be interrpretted as  'A-B B-A a-b b-a'  .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 04:44:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914574#M1598007</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T04:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914575#M1598008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use regular expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : lv_regex TYPE string VALUE '[''"]',&lt;/P&gt;&lt;P&gt;             lv_str   TYPE string VALUE '""''text''""'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPLACE ALL OCCURRENCES OF REGEX lv_regex IN lv_str WITH ''.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE lv_str.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marvin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 05:57:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914575#M1598008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T05:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914576#M1598009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marvin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much.  I have decided to use regular expressions but just had to modify your code cause it didn't work as expected.  Had to do the data as this and all works as expected:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:  lv_regex TYPE string VALUE '''|\"'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if anyone has any suggestions for Question number 2 in my original post else I'm just going with this solution only.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 07:07:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914576#M1598009</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-17T07:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing specified characters from string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914577#M1598010</link>
      <description>METHOD remove_special_chars .&lt;BR /&gt;    DATA:&lt;BR /&gt;      lv_allowed_char_m340(100) TYPE c VALUE ' &amp;amp;,-.0123456789:;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_/()~'.&lt;BR /&gt;&lt;BR /&gt;    FIELD-SYMBOLS: &amp;lt;fs_cell&amp;gt; TYPE simple.&lt;BR /&gt;    LOOP AT tab ASSIGNING FIELD-SYMBOL(&amp;lt;fs_hdr&amp;gt;).&lt;BR /&gt;      DO.&lt;BR /&gt;        ASSIGN COMPONENT sy-index OF STRUCTURE &amp;lt;fs_hdr&amp;gt; TO &amp;lt;fs_cell&amp;gt;.&lt;BR /&gt;        IF sy-subrc NE 0. EXIT. ENDIF.&lt;BR /&gt;&lt;BR /&gt;        DO.&lt;BR /&gt;          IF &amp;lt;fs_cell&amp;gt; CN lv_allowed_char_m340.&lt;BR /&gt;            &amp;lt;fs_cell&amp;gt;+sy-fdpos(1) = '~'.&lt;P&gt;    "This is not actually allowed, so using as my spacer to replace later&lt;/P&gt;&lt;P&gt;          ELSE.&lt;/P&gt;            EXIT.&lt;BR /&gt;          ENDIF.&lt;BR /&gt;        ENDDO.&lt;BR /&gt;&lt;BR /&gt;        REPLACE ALL OCCURRENCES OF '~' IN &amp;lt;fs_cell&amp;gt; WITH ''.&lt;BR /&gt;      ENDDO.&lt;BR /&gt;    ENDLOOP.&lt;BR /&gt;&lt;P&gt;  ENDMETHOD.best way i have found:&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 01:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-specified-characters-from-string/m-p/7914577#M1598010</guid>
      <dc:creator>former_member823527</dc:creator>
      <dc:date>2022-07-15T01:18:41Z</dc:date>
    </item>
  </channel>
</rss>

