Get partial Value in the innertext

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
mariya.syera
Posts: 9
Joined: Wed Nov 08, 2017 10:59 pm

Get partial Value in the innertext

Post by mariya.syera » Thu Mar 08, 2018 1:25 am

What do I need to enter in Capture Regex to get a value in the middle of the text?

Get "123456" Value from: Visit 123456 has been created successfully.
or
Get "Test" value from: Visit Test has been created successfully

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get partial Value in the innertext

Post by odklizec » Thu Mar 08, 2018 8:59 am

Hi,

You can use this regex, to extract number from string:
\d+
And this one for extracting string after "Visit" (+ space) string:
(?<=Visit\s)[^\s]+
Hope this helps? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mariya.syera
Posts: 9
Joined: Wed Nov 08, 2017 10:59 pm

Re: Get partial Value in the innertext

Post by mariya.syera » Thu Mar 08, 2018 4:40 pm

Thank you!
Mariya Syera
Office Ally, Inc

TimoL
Posts: 46
Joined: Thu Sep 13, 2018 3:08 pm

Re: Get partial Value in the innertext

Post by TimoL » Tue Oct 08, 2019 11:55 am

The string is in format: AA - BB - CC - DD. I would like to capture the last part of the string, i.e. DD (the DD string contains spaces). Regex capture (?<=\-\s)(?s)(.*$) returns BB - CC - DD. But how to capture the part after the last minus and space?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get partial Value in the innertext

Post by odklizec » Tue Oct 08, 2019 12:16 pm

Hi,

Try this...
[^- \s]+$
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

TimoL
Posts: 46
Joined: Thu Sep 13, 2018 3:08 pm

Re: Get partial Value in the innertext

Post by TimoL » Tue Oct 08, 2019 12:35 pm

odklizec wrote:
Tue Oct 08, 2019 12:16 pm
Hi,

Try this...
[^- \s]+$
Thanks, but the last part contains spaces, so the DD can be for example "the last string". [^- \s]+$ captures "string" only. I would like to get everything after the last minus and space.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get partial Value in the innertext

Post by odklizec » Tue Oct 08, 2019 2:38 pm

What about this?...
[^-\s][^-]+$
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

TimoL
Posts: 46
Joined: Thu Sep 13, 2018 3:08 pm

Re: Get partial Value in the innertext

Post by TimoL » Wed Oct 09, 2019 5:13 am

That worked, thanks a lot!