UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Commander Commander
Commander
212 views

Shorten the value

I have a field where I get the value using this code:

LoginUser = Browser("eVoucher 7_4").Page("eVoucher 7").WebElement("Welcome, Patrick Jones").GetROProperty("innertext")

Value = Welcome, Patrick Jones (Court Staff) Logout

I would like to shorten the value to equal  " Court Staff"

only thing is the value between the "(     )" could be different , Judge, Attorney, etc

Can anyone help?

0 Likes
2 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

You can do this using the Split command.

https://devguru.com/content/technologies/vbscript/functions-split.html

Mark Smith.

0 Likes
Micro Focus Expert
Micro Focus Expert

You may also use regular expression.

 

Set objRE = New RegExp

With objRE
.Pattern = "Welcome.*\((.*)\)+"
.IgnoreCase = True
.Global = False
End With


x = "Welcome, Patrick Jones (Court Staff) Logout"

Set objMatch = objRE.Execute( x )

' We should get only 1 match since the Global property is FALSE
txt = "empty"
If objMatch.Count = 1 Then
txt = objMatch.Item(0).submatches(0)
print txt
msgbox txt
End If

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.