web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use indexOf syn...
Power Automate
Unanswered

How to use indexOf syntax as value in "Set Variable" of Power automate desktop

(0) ShareShare
ReportReport
Posted on by 6

Hi 

I want to find index of a particular word from extracted text and use it further to extract data after the word. How to do it?

 

Regards

Vikas

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    The action is called Parse Text and it returns the %Position% of the text in "Text to find".

     

    For example, if I had the text "0123456789" and said Parse Text find "5", it would return 5 as the position (it is a 0-base index).  So, then I can use Get Subtext on the same variable start character position 5 to the end of text and get "56789" as a result.

     

    I have 4 articles covering text actions located here starting at 5.0 through 5.3:

     

    https://www.linkedin.com/in/michael-annis-80903/recent-activity/posts/

     

     

    Best of luck!

     

    MichaelAnnis_0-1667495454750.png

    MichaelAnnis_1-1667495607591.png

     

     

  • VikasKaushik Profile Picture
    6 on at

    Thank you Michael!

    Attached is the sample extract of a pdf file, need to extract the highlighted portion from the entire text. How to do it please? Apart from a resolution to this, need to know Is there a way to use syntax's in any action in Power automate desktop specially to set value of variable? If yes, how to do it?

     

    VikasKaushik_0-1667499889105.png

     

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    Hi @VikasKaushik 

    You can use regex with lookups to find what you need.

    Depending on what is in the text, you could use:

     

    1. Search 6 digits in a row, if there is no other such number in the text - risky 

     

     

    \d{7}​

     

     

    • Search 6 digits that appear before "-" and another digit using a lookahead. Safer. 

     

     

    \d{7}(?=-\d)​

     

     

    • Use both lookahead and lookbehind to pinpoint exact data - My preferred way.

     

     

    (?<=Customer number\t)\d{7}(?=-\d)​

     

     

    So:

    Action 1 - read text from the PDF

    Action 2 - Analyze text with regex, output match as a variable

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    There are lots of ways to do it but you could split text by line to %SplitText%, loop on the list, if contains customer number, split that line by tab to %NewList% and take the second part of the new list: %NewList[1]%.

  • Riyaz_riz11 Profile Picture
    4,214 Super User 2026 Season 1 on at

    Hi @VikasKaushik 

     

    Please look into this,

    Ahammad_Riyaz_0-1667805928232.png

     

    Regards

    Ahammad Riyaz

    --------------------------------------------------------------------------------
    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

     

     

  • VikasKaushik Profile Picture
    6 on at

    Thanks!

    This works.

    \d{7}(?=-\d)​

    This one is not working, this will be a secured solution if works.

    (?<=Customer number\t)\d{7}(?=-\d)​

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 248 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 204

#3
Haque Profile Picture

Haque 179

Last 30 days Overall leaderboard