Issues with get value/regex

Ask general questions here.
andy.simpson
Posts: 59
Joined: Fri Jun 22, 2018 8:59 am

Issues with get value/regex

Post by andy.simpson » Thu Oct 17, 2019 9:53 am

Hi,

I'm having an issue where I want to use get value and regex to strip off the characters/whitespace and just be left with numbers and decimals. I have used the regex tool within Ranorex and found two solutions that would be suitable however when I run through the test the figure that is processed is not the expected one. Bizarrely I have used two completely different methods which both result in the same wrong figure, cant really see how its possible

59.4 GB with a regex of [^ GB]
Expected result 59.4
Actual result 5

59.4GB with a regex of [1-9.]
Expected result 59.4
Actual result 5

I have attached pictures of the test results any ideas would be appreciated
You do not have the required permissions to view the files attached to this post.

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

Re: Issues with get value/regex

Post by odklizec » Thu Oct 17, 2019 11:13 am

Hi,

Try this:

Code: Select all

.+(?=\sGB)
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

andy.simpson
Posts: 59
Joined: Fri Jun 22, 2018 8:59 am

Re: Issues with get value/regex

Post by andy.simpson » Fri Oct 18, 2019 10:54 am

That works thanks :) how is it that works and my other solutions didn't?

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

Re: Issues with get value/regex

Post by odklizec » Fri Oct 18, 2019 11:12 am

Hi,

My solution uses positive lookahead, where it searches for 'space' (\s) followed by 'GB' string and then it returns all characters before the found string (in one group).

Both your solutions match individual characters and not entire string, so they both returns 4 individual groups, containing '5', '9', '.' and '4'. And Ranorex apparently obtains first match, so you thought it returned only '5' ;) Try both your and mine solution in Ranorex Regex toolkit and you will see what I mean.
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