Any WinAutomation guru's here?

5 replies
Are there any WA folk here who can give me a hand with creating a search and replace regex for the parse text action?

I need to replace the first instance of a matched word in a text stream, even if there are more matches.

The replace text works on an all or nothing basis, so that's not suitable in this case, as it replaces every instance of the matched word in the stream.

Would appreciate it if someone can help.

Thanks,
Will.
#guru #winautomation
  • Profile picture of the author Aj Wilson
    I believe you can replace a targeted instance...

    first, second, last, etc.

    However, have you tried posting in the WinAutomation Forum?
    Those guy are ultra helpful, and usually always reply.

    - aj
    Signature
    {{ DiscussionBoard.errors[2002123].message }}
  • Profile picture of the author WillDee
    Thanks for the reply aj. I did post a message on the forum at WA, and also fired off an email to their support guys, but hadn't had a response, so tried here. I don't know about previous versions, but in the latest version it looks like the replace text action is a global action and replaces everything.
    {{ DiscussionBoard.errors[2004994].message }}
    • Profile picture of the author Aj Wilson
      Hey Will,

      Try this,

      "Parse" your text.
      Make sure you have "find first occurrence only" ticked.

      Then look at the Action Output.

      It's the bottom box you should be interested in,
      Store Match(es) into : %variable%

      This will find "the first occurrence only"
      and store it in this variable.

      Next.

      Open "replace text" and parse your text.
      then you want to "find" your %variable% but Only replace the first occurrence.

      So your "find" text would be something like : %variable[variable.Count0]%

      Which targets only the first occurrence of the stored variable.
      try %variable[variable.Count0]%
      or %variable[variable.Count1]%

      I cant quite remember which is which now. lol.

      Then "replace it" with whatever you want (which could be another
      %variable% if you wanted to).

      Hope this helps you out,
      all the best mate.

      - aj
      Signature
      {{ DiscussionBoard.errors[2014863].message }}
  • Profile picture of the author WillDee
    Thanks AJ.

    Got it working.
    {{ DiscussionBoard.errors[2021072].message }}

Trending Topics