Question regarding extracting a portion of a string

Hello,

I have an issue regarding extracting a portion of a string.

I’m using the ‘Use Application/Browser’ activity and am extracting the Output Element to a UiElement variable titled outputWindow.

When I output outputWindow to a log message activity using outputWindow.Selector.ToString, the details of the extracted variable are:
(less than symbol)wnd app=‘saplogon.exe’ cls=‘SAP_FRONTEND_SESSION’ title=‘List 0002 - Personal Data’ /(more than symbol)

I am wanting to extract what’s after title=, and only what’s between the inverted commas; e.g. List 0002 - Personal Data.

Could someone please tell me how to do this? I’ve looked at the string manipulation article, but I’m just not getting it.

Thank you very much

hey

you can use a get attribute activity and pass your element variable in input element property like this

use app/browser:

Get attribute:

output

Regards!

1 Like

@Clintonnn Assign this below code to a string,
TitleVar(Of String type) = System.Text.RegularExpressions.Regex.Match(outputWindow.Selector.ToString,“title=(‘|')([A-z0-9\s-]+)”).Groups(2).Value
And also you can get this value using ‘Get Attribute’ activity.

Hope this may help you :slight_smile:

1 Like

Hi

There are two ways to do this

  1. Let us consider with what you have done already

You can use ur current method itself where just use the above expression alone like this in assign activity

str_title = System.Text.RegularExpressions.Regex.Match(outputWindow.Selector.ToString.Trim, “(?<=title=\W).*(?=\W\s)”).ToString.Trim

As simple as that

  1. Another method, a First and most simple thing is with GET ATTRIBUTE activity
  • have the use application/ browser activity and indicate on the application
  • then get the output from that activity named as out_element
  • now use a GET ATTRIBUTE ACTIVITY inside that use application/browser activity and pass the UiElement variable as input to INPUT ELEMENT Property
  • mention attribute as Title - the one you want and get the output as a string variable named str_title

Though you have mentioned as Title you need only the text between quotes and not completely
So use a Regex like this

In Assign activity

str_title = System.Text.RegularExpressions.Regex.Match(str_title.ToString.Trim, “(?<=title=\W).*(?=\W\s)”).ToString.Trim

Cheers @Clintonnn

1 Like

Fantastic, thanks for your help!

Thank you also @Manish540 and @fernando_zuluaga

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