Studio: RegEx on a Web Application

Hi,
I work on a web application. I want to fetch data from the application window using RegEx. Is RegEx work on web application ? If so, can you please show example ? I mean if I have a data on the website page like this:
Remittance Details: Online
Task Cover: PO41991

I want to capture it like this Online and PO41991. How to do it using RegEx?

Hi @Prinal_C,

You could use a Get Text or Get Full Text activity to get the value and then Regex the data picked up. Could you supply a screenshot of the web application with the data you are attempting to get?

@william.coulson sorry cannot share screenshot. The Ui is like this:
Remittance Details: Online

This entire thing is in a text format. If I go GetText then the whole thing shows up like this “Remittance Details: Online”. I only need Online.
Are you saying I can use RegEx after this step ?

You shall read the entire text with Get text and assign it to a variable say text1 & text2 respectively.

Use Assign activities,

remittanceDetails = text1.split(“ :”)(1).ToString

taskCover = text2.split(“ :”)(1).ToString

Now you will have your required values in the variables remittanceDetails & taskCover.

Cheers,
Jesh

Hello

If your string looks like this then check out these Regex Patterns.
Regex for Online
Regex for Task Cover

You can use an Assign activity like this:

Left of Assign:

Str_Variable

Right of Assign:

System.Text.RegularExpressions.Regex.Matches(INPUT_STRING,“INSERT_REGEX_PATTERN”)( 0 ).ToString

Just Insert Regex Pattern from the attached links.

If you want to learn Regex check out my MegaPost

Hopefully this helps :slight_smile:

1 Like

Hi @Prinal_C,

Yes, you need to get the data first in order to Regex or Manipulate it. as @jeshwanthaloy has suggested, you can use a split function instead of Regex:

WantedText = ScrapedText.Split({":"},StringSplitOptions.None).Last.Trim

Or @jeshwanthaloy’s:

1 Like

Fine

Let’s go in a simple way of approach

Say your website has multiple other text as well along with this

  1. Then first use a GET TEXT activity to get all text you want from that page
    And even you can get the text from a specific region of that page

  2. Get the output in a string datatype named Strinput

  3. Then use a assign activity like this

stroutput_1 = System.Text.RegularExpressions.Regex.Match(Strinput.ToString,”(?<=Remittance Details:).*”).ToString.Trim

Stroutput_1 will give ”Online” as output

Then use another assign activity like this

stroutput_2 = System.Text.RegularExpressions.Regex.Match(Strinput.ToString,”(?<=Task Cover:).*”).ToString.Trim

Stroutput_2 will give ”PO41991” as output

Hope this would help you resolve this
Cheers @Prinal_C

1 Like

Small Tips: you can import System.Text.RegularExpressions from import panel and then no need to write this namespace everytime you use regex, just type Regex.Match or anything else…

1 Like

Thank you all.

1 Like

Glad @Prinal_C

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.