<?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: Occurrence for a pattern in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793266#M2024477</link>
    <description>&lt;P&gt;BIG WARNING: PCRE exists only since ABAP 7.55&lt;/P&gt;&lt;P&gt;Before 7.55, using REGEX POSIX is highly NOT recommended due to performance, failures at runtime depending on input string, etc., classic FIND stuff is recommended.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2023 06:58:22 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-08-10T06:58:22Z</dc:date>
    <item>
      <title>Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793259#M2024470</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I am trying to find a solution to break this string into 3 variables&lt;/P&gt;
  &lt;P&gt;(240)1007712(10)0001212585(21)10&lt;/P&gt;
  &lt;P&gt;Var1 = 1007712&lt;/P&gt;
  &lt;P&gt;Var2 = 0001212585&lt;/P&gt;
  &lt;P&gt;Var3 = 10&lt;/P&gt;
  &lt;P&gt;Appreciate for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 16:19:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793259#M2024470</guid>
      <dc:creator>former_member188001</dc:creator>
      <dc:date>2023-08-09T16:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793260#M2024471</link>
      <description>&lt;P&gt;What did you find already, just to help us help you?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 17:59:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793260#M2024471</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-09T17:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793261#M2024472</link>
      <description>&lt;P&gt;I guess it's not what you are asking?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data(text) = '(240)1007712(10)0001212585(21)10'.
data(var1) = substring( val = text off = 5 len = 7 ).
...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Maybe you could tell us what the rules are?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 18:00:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793261#M2024472</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-09T18:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793262#M2024473</link>
      <description>&lt;P&gt;Var1 = 1007712 -&amp;gt; This is not fixed. This can vary&lt;/P&gt;&lt;P&gt;Var2 = 0001212585 -&amp;gt; This is not fixed. This can vary&lt;/P&gt;&lt;P&gt;That is the reason i cant put an offset. I am trying to find a way to read the values between ) and (&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 19:04:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793262#M2024473</guid>
      <dc:creator>former_member188001</dc:creator>
      <dc:date>2023-08-09T19:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793263#M2024474</link>
      <description>&lt;P&gt;ok thank you&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;trying to find a way to read the values between ) and (&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Use FIND.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensearch_functions.htm"&gt;ABAP Keyword Documentation (sap.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 19:49:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793263#M2024474</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-09T19:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793264#M2024475</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;DATA(text) = '(240)1007712(10)0001212585(21)10'.
DATA(regex) = '\(\d+\)(\d+)\(\d+\)(\d+)\(\d+\)(\d+)'.
DATA(matcher) = cl_abap_regex=&amp;gt;create_pcre( pattern = regex
     )-&amp;gt;create_matcher( text = text ).
IF matcher-&amp;gt;match( ).
  DATA(lv_str1) = matcher-&amp;gt;get_submatch( 1 ).
  DATA(lv_str2) = matcher-&amp;gt;get_submatch( 2 ).
  DATA(lv_str3) = matcher-&amp;gt;get_submatch( 3 ).
  cl_demo_output=&amp;gt;display( |str1:{ lv_str1 } str2:{ lv_str2 } str3:{ lv_str3 }| ).
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2197447-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 01:32:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793264#M2024475</guid>
      <dc:creator>xiaosanyu</dc:creator>
      <dc:date>2023-08-10T01:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793265#M2024476</link>
      <description>&lt;P&gt;If string contains letters，you can change the regex to &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA(regex) = '\(\w+\)(\w+)\(\w+\)(\w+)\(\w+\)(\w+)'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2023 01:38:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793265#M2024476</guid>
      <dc:creator>xiaosanyu</dc:creator>
      <dc:date>2023-08-10T01:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793266#M2024477</link>
      <description>&lt;P&gt;BIG WARNING: PCRE exists only since ABAP 7.55&lt;/P&gt;&lt;P&gt;Before 7.55, using REGEX POSIX is highly NOT recommended due to performance, failures at runtime depending on input string, etc., classic FIND stuff is recommended.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 06:58:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793266#M2024477</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-10T06:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793267#M2024478</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;salil.vaidya4&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;More generically, we can do something like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lt_result TYPE TABLE OF string.&lt;BR /&gt;&lt;BR /&gt;DATA(lv_string) = '(240)1007712(10)0001212585(21)10'.&lt;BR /&gt;&lt;BR /&gt;REPLACE ALL OCCURRENCES OF PCRE '\(\d+\)' IN lv_string WITH '-'.&lt;BR /&gt;&lt;BR /&gt;DO.&lt;BR /&gt;  SPLIT lv_string AT '-' INTO DATA(lv_var1) DATA(lv_var2).&lt;BR /&gt;  APPEND lv_var1 TO lt_result.&lt;BR /&gt;  lv_string = lv_var2.&lt;BR /&gt;  IF lv_var2 IS INITIAL.&lt;BR /&gt;    EXIT.&lt;BR /&gt;  ENDIF.&lt;BR /&gt;ENDDO.&lt;BR /&gt;&lt;BR /&gt;cl_demo_output=&amp;gt;display( lt_result ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 07:56:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793267#M2024478</guid>
      <dc:creator>adityaIngale66</dc:creator>
      <dc:date>2023-08-10T07:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793268#M2024479</link>
      <description>&lt;P&gt;I put this question through chat-gpt &lt;/P&gt;&lt;EM&gt;Write me a clean ABAP OO program that will parse a string like this: (240)1007712(10)0001212585(21)10

The  (n*) are the delimiter. 
 &lt;/EM&gt;&lt;P&gt;&lt;EM&gt;Do not use REGEX.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It proved incapable.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 08:57:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793268#M2024479</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2023-08-10T08:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793269#M2024480</link>
      <description>&lt;P&gt;Thanks all for your help and comments. Unfortunately we are on 750, so PCRE is not available. &lt;/P&gt;&lt;P&gt;I took some suggestion from the answers above and wrote the following. This seems to work. Please let me know if you see any issues here.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;text = (240)1007712(10)0001212585(21)10

replace ALL OCCURRENCES OF '(' in text WITH '-'.

replace ALL OCCURRENCES OF ')' in text WITH '-'.

SPLIT text AT '-' INTO DATA(lv_var1) DATA(lv_var2) DATA(lv_var3) DATA(lv_var4) DATA(lv_var5) DATA(lv_var6).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2023 14:38:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793269#M2024480</guid>
      <dc:creator>former_member188001</dc:creator>
      <dc:date>2023-08-10T14:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Occurrence for a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793270#M2024481</link>
      <description>&lt;P&gt;Just a comment about the way of writing the answer, variable numbers are confusing, compared to the question, I would write:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;text = '(240)1007712(10)0001212585(21)10'.

replace ALL OCCURRENCES OF '(' in text WITH '-'.
replace ALL OCCURRENCES OF ')' in text WITH '-'.

ASSERT text = '-240-1007712-10-0001212585-21-10'.

SPLIT text AT '-' INTO DATA(dummy1) DATA(dummy2) DATA(Var1) DATA(dummy3) DATA(Var2) DATA(dummy4) DATA(Var3).

ASSERT Var1 = '1007712'.
ASSERT Var2 = '0001212585'.
ASSERT Var3 = '10'.

ASSERT dummy1 = ''.
ASSERT dummy2 = '240'.
ASSERT dummy3 = '10'.
ASSERT dummy4 = '21'.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ASSERT "does nothing" but aborting if the condition is false, so it's just for the demo and ease of reading.&lt;/P&gt;&lt;P&gt;Disclaimer: code above not tested.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 19:06:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/occurrence-for-a-pattern/m-p/12793270#M2024481</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-10T19:06:58Z</dc:date>
    </item>
  </channel>
</rss>

