Skip to main content

Notifications

Power Automate - Power Automate Desktop
Answered

Regex - parsing text after third appearance of sign "$"

(1) ShareShare
ReportReport
Posted on by 9
Hi,
 
I have a following text:
 
"$1234 $2345 $3456"
 
 
What I need is to parse a number appearing after third appearance of the sign "$", which is "3456".
 
I used regex working on regex101:
 
 
...but in PAD this one results in "0".
 
I had couple of other options. Below regexes and results in PAD:
 
^(?:[^$]*\$){3}(.*) result: "0"
(?:[^$]*\$){3}([^$]*) result: "0"
\\$(.*) result: "0"
(?<=([^$]*\$){3})\s*(.*) result: "13"
(?<=([^$]*\$){3}).* result: "13"
 
I also played around with removing white spaces in "$1234 $2345 $3456" before applying regexes.
 
Actually, I figured out, that I can simply parse three times text appearing after "$", but still, it bothers me that none of these regexes parsing text after third appearance work. Also, I don't know how big the project will be, so it would be cool to have one line of code, instead of three to have it done. 
 
Many thanks for any ideas!
Categories:
  • Suggested answer
    eetuRobo Profile Picture
    eetuRobo 2,687 on at
    Regex - parsing text after third appearance of sign "$"
    @PawelSlon

    I think you are looking at the wrong output variable. You are looking at the "Position" which just returns the position which the text is found. Look at the Match variables value and it should be same as in Deenuji_Loganathans, picture: 3456


    ps. I think you should mark Deenujis answer as the solution
  • Verified answer
    PawelSlon Profile Picture
    PawelSlon 9 on at
    Regex - parsing text after third appearance of sign "$"
     
    thanks for your answer. 
     
    I was looking for that solution using Perplexity.ai, regex101.com, as well as stackoverflow.com. Will add chat GPT to my sources:)
     
    Your solution is interesting, though it gives me result "13" in PAD. Though it works on regex101:/ Is it a PAD issue?
     
    Regards,
     
    Paweł
  • Suggested answer
    Deenuji_Loganathan_ Profile Picture
    Deenuji_Loganathan_ 6,080 on at
    Regex - parsing text after third appearance of sign "$"
    Hi Pawel,
     
    I recommend using ChatGPT generate your regex for your business requirements.
     
    This solution was provided by ChatGPT and it has been working well for me.
     
    Regex: 
    \d+(?=[^$]*$)

    Flow Screenshot:

     
    Full code (Copy and paste the below code into your power automate desktop flow):
    SET StrValue TO $'''$1234 $2345 $3456'''
    Display.InputDialog Title: $'''Info''' Message: $'''Enter the data''' InputType: Display.InputType.SingleLine IsTopMost: False UserInput=> StrValue ButtonPressed=> ButtonPressed2
    Text.ParseText.RegexParseForFirstOccurrence Text: StrValue TextToFind: $'''\\d+(?=[^$]*$)''' StartingPosition: 0 IgnoreCase: True OccurrencePosition=> Position Match=> Match
    Display.ShowMessageDialog.ShowMessage Title: $'''Info''' Message: Match Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    
     
    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard