<?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: Get a paticular value BEG[03] from a single line using formula in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5749#M2521</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ISA*00* *00* *ZZ*TEST *ZZ*OTFWTESTUS *231201*2330*U*00401*000000003*0*P*&amp;gt;~GS*PO*TEST*OTFWTESTUS*20231201*2330*3*X*004010VICS~ST*850*0003&lt;STRONG&gt;~BEG*00*RL*823127&lt;/STRONG&gt;**20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025779*VC*5779~PO1*2*6*EA*20.90*WE*UP*816218026042*VC*6042~PO1*3*3*EA*19*WE*UP*816218028749*VC*8749~CTT*3~SE*15*0003~ST*850*0004~&lt;STRONG&gt;BEG*00*RL*823128&lt;/STRONG&gt;**20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025786*VC*5786~PO1*2*3*EA*20.90*WE*UP*816218026004*VC*6004~PO1*3*6*EA*20.90*WE*UP*816218026028*VC*6028~CTT*3~SE*15*0004~GE*2*3~IEA*1*000000003~&lt;/P&gt;&lt;P&gt;They have changed the file content that we will get multiple &lt;STRONG&gt;BEG&lt;/STRONG&gt;&amp;nbsp;segment in a single line, I want to get 4th index of the&amp;nbsp; BEG segment each(we may have multiple BEG in a single line) and &lt;STRONG&gt;update 3rd index that is RL to RE&lt;/STRONG&gt; wherever BEG segment is present.&lt;/P&gt;&lt;P&gt;I am not able to do that as length is varying between each BEG segment.&lt;/P&gt;&lt;P&gt;Could you please help me on this? it would be very helpful for me.&lt;/P&gt;&lt;P&gt;Thanks so much in advance.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2023 03:05:47 GMT</pubDate>
    <dc:creator>MurugarajSa</dc:creator>
    <dc:date>2023-12-04T03:05:47Z</dc:date>
    <item>
      <title>Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5743#M2517</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;ISA*00* *00* *ZZ*TEST *ZZ*HOGAN *231129*1551*U*00401*000000001*0*P*&amp;gt;~GS*PO*MARY*HOG*20231129*1551*1*X*004010VICS~ST*850*0001~BEG*00*RL*&lt;STRONG&gt;823120&lt;/STRONG&gt;**20231129~FOB*DF~ITD*05*2*****30~&lt;/P&gt;&lt;P&gt;I will receive one file and will have above line where length might be vary based on the file. I need to get value of&amp;nbsp; "823120" and store it in a variable to use it later.&lt;/P&gt;&lt;P&gt;BEG*00*RL*&lt;STRONG&gt;823120 --&lt;/STRONG&gt; I would say 3rd argument of BEG segment.&lt;/P&gt;&lt;P&gt;Any formula I can use to get the value from a single line&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 06:33:47 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5743#M2517</guid>
      <dc:creator>MurugarajSa</dc:creator>
      <dc:date>2023-12-01T06:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5746#M2518</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This finds the location of "BEG", slices off the rest of the string, splits the remainder into an array, and returns the 4th index.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gary1_0-1701413127072.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/892i43F6BDA6C1B84297/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="gary1_0-1701413127072.png" alt="gary1_0-1701413127072.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Because "BEG" might appear elsewhere in the string, this one may be more reliable if the start of the "BEG" segment is always formatted as "~BEG*"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gary1_1-1701413289185.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/893i80239CCAEF835326/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="gary1_1-1701413289185.png" alt="gary1_1-1701413289185.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's the formula as text so you can copy/paste. Just replace both "x" variables with the data pill.&lt;/P&gt;&lt;P&gt;x.slice(x.index("~BEG*")..-1).split('*')[3]&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 06:50:17 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5746#M2518</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2023-12-01T06:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5747#M2519</link>
      <description>&lt;P&gt;Thanks for your quick reply and it worked perfectly&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 15:30:55 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5747#M2519</guid>
      <dc:creator>MurugarajSa</dc:creator>
      <dc:date>2023-12-01T15:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5749#M2521</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ISA*00* *00* *ZZ*TEST *ZZ*OTFWTESTUS *231201*2330*U*00401*000000003*0*P*&amp;gt;~GS*PO*TEST*OTFWTESTUS*20231201*2330*3*X*004010VICS~ST*850*0003&lt;STRONG&gt;~BEG*00*RL*823127&lt;/STRONG&gt;**20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025779*VC*5779~PO1*2*6*EA*20.90*WE*UP*816218026042*VC*6042~PO1*3*3*EA*19*WE*UP*816218028749*VC*8749~CTT*3~SE*15*0003~ST*850*0004~&lt;STRONG&gt;BEG*00*RL*823128&lt;/STRONG&gt;**20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025786*VC*5786~PO1*2*3*EA*20.90*WE*UP*816218026004*VC*6004~PO1*3*6*EA*20.90*WE*UP*816218026028*VC*6028~CTT*3~SE*15*0004~GE*2*3~IEA*1*000000003~&lt;/P&gt;&lt;P&gt;They have changed the file content that we will get multiple &lt;STRONG&gt;BEG&lt;/STRONG&gt;&amp;nbsp;segment in a single line, I want to get 4th index of the&amp;nbsp; BEG segment each(we may have multiple BEG in a single line) and &lt;STRONG&gt;update 3rd index that is RL to RE&lt;/STRONG&gt; wherever BEG segment is present.&lt;/P&gt;&lt;P&gt;I am not able to do that as length is varying between each BEG segment.&lt;/P&gt;&lt;P&gt;Could you please help me on this? it would be very helpful for me.&lt;/P&gt;&lt;P&gt;Thanks so much in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 03:05:47 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5749#M2521</guid>
      <dc:creator>MurugarajSa</dc:creator>
      <dc:date>2023-12-04T03:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5750#M2522</link>
      <description>&lt;P&gt;Can you provide an example of what you expect as output from the formula when processing the new input text?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 04:34:06 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5750#M2522</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2023-12-04T04:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5751#M2523</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;.&lt;/P&gt;&lt;P&gt;ISA*00* *00* *ZZ*TEST *ZZ*OTFWTESTUS *231201*2330*U*00401*000000003*0*P*&amp;gt;~GS*PO*TEST*OTFWTESTUS*20231201*2330*3*X*004010VICS~ST*850*0003&lt;STRONG&gt;~BEG*00*RE*823127*&lt;/STRONG&gt;*20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025779*VC*5779~PO1*2*6*EA*20.90*WE*UP*816218026042*VC*6042~PO1*3*3*EA*19*WE*UP*816218028749*VC*8749~CTT*3~SE*15*0003~ST*850*0004&lt;STRONG&gt;~BEG*00*RE*823128*&lt;/STRONG&gt;*20231201~FOB*DF~ITD*05*2*****30~DTM*001*20231231~DTM*010*20231201~N1*ST*Georgetown*92*172002~N2*test, inc~N3*3059 M Street NW~N4*Washington*DC*20007~PO1*1*3*EA*20.90*WE*UP*816218025786*VC*5786~PO1*2*3*EA*20.90*WE*UP*816218026004*VC*6004~PO1*3*6*EA*20.90*WE*UP*816218026028*VC*6028~CTT*3~SE*15*0004~GE*2*3~IEA*1*000000003~&lt;/P&gt;&lt;P&gt;Above is the expected output result.&lt;/P&gt;&lt;P&gt;1st thing is Need to extract value of&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;823127 and&amp;nbsp;823128 &lt;/STRONG&gt;&lt;/EM&gt;from BEG segment and store it in a variable to use it later(&lt;SPAN&gt;concatenate&amp;nbsp;&lt;/SPAN&gt;would be fine. e.g&amp;nbsp;&lt;STRONG&gt;823127 |&amp;nbsp;&lt;EM&gt;823128 &lt;/EM&gt;&lt;/STRONG&gt;). we may have mutiple BEG segment in a single line and length may vary between each BEG.&lt;/P&gt;&lt;P&gt;2nd thing is to update&amp;nbsp;&lt;STRONG&gt;*RL* to *RE* in BEG segment.&lt;/STRONG&gt; we can use &lt;STRONG&gt;gsub &lt;/STRONG&gt;but&amp;nbsp;do we have any other efficient way?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 04:55:26 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5751#M2523</guid>
      <dc:creator>MurugarajSa</dc:creator>
      <dc:date>2023-12-04T04:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5755#M2524</link>
      <description>&lt;P&gt;I don't think all of this could be done in a single line (at least not by me!), so I wrote a quick code snippet you can use in a Ruby action. It will output the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;begIDs: an array of BEG ID values&lt;/LI&gt;&lt;LI&gt;begSegmentsFinal: an array of updated BEG segments after replacing *RL* with *RE* -- this is mostly for reference, but I included it anyway&lt;/LI&gt;&lt;LI&gt;updatedInput: this is the entire string input updated after&amp;nbsp;replacing *RL* with *RE*&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here's the actual output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gary1_2-1701670966961.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/896i74B92AB2077DE345/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="gary1_2-1701670966961.png" alt="gary1_2-1701670966961.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Set up a Ruby action with one string input called "string", and pass in your string.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gary1_0-1701670531650.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/894i2F63907D70B1F54F/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="gary1_0-1701670531650.png" alt="gary1_0-1701670531650.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Set up the output like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gary1_1-1701670611126.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/895iBE7C8CCD4C3E9A48/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="gary1_1-1701670611126.png" alt="gary1_1-1701670611126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;string = input[:string]

begSegments = string.scan(/(~BEG\*\d{2}\*[A-Z]{2}\*\d+\*\*)/).flatten
begIds = []
begSegmentsFinal = []
updatedInput = ''

begSegments.each { | s | 
  begIds.push(s.split('*')[3])
  begSegmentUpdated = s.include?('*RL*') ? s.gsub('*RL*','*RE*') : s
  begSegmentsFinal.push(begSegmentUpdated)
  updatedInput = string.gsub(s, begSegmentUpdated)
}

{
  begIds: begIds,
  # if you want a comma-delimited list, just use begIds.join(',') but you'll also have to update the output schema so begIds is a string and not an array
  begSegmentsFinal: begSegmentsFinal,
  updatedInput: updatedInput
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It first uses a regex to find the BEG segments up to the ID value. Then it loops through the array of matches and uses gsub to replace RL/RE. In my opinion, this is a bit more selective/careful because it's only doing it on a portion of the BEG segment and not the entire input string where other instances of *RL*&amp;nbsp;&lt;EM&gt;might&lt;/EM&gt; exist, but I have no idea.&lt;/P&gt;&lt;P&gt;There are probably better or more efficient ways of doing this, but this should work until it doesn't!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 06:25:43 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5755#M2524</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2023-12-04T06:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get a paticular value BEG[03] from a single line using formula</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5758#M2525</link>
      <description>&lt;P&gt;Thank you very much for your solution&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/1188"&gt;@gary1&lt;/a&gt;&amp;nbsp;. it worked perfectly for my scenario.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 10:40:34 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/get-a-paticular-value-beg-03-from-a-single-line-using-formula/m-p/5758#M2525</guid>
      <dc:creator>MurugarajSa</dc:creator>
      <dc:date>2023-12-04T10:40:34Z</dc:date>
    </item>
  </channel>
</rss>

