Hey everyone, I am getting a text from Get Text activity and it is basically a string. It could be like 8-9, 2-7, or any n-n range and <, > signs with n as well for example <10, >10. I have to check that if the Duration of residence (n) is <10 then I should return true else return false.
Similarly, I am getting another string, if it contains age between 60-64 or >65 then I have to return true else false.
I am attaching the screenshot of my problem for more clarity.
what if my string contains Duration of residence 5? Which means it is less then 10. Similarly if age is 72 it is greater than 65. In both cases strings are not containing <10 and >65 but are still true.
To check if the Duration of residence (n) is less than 10 or not, you can use the following steps:
Use the Matches activity to extract the numerical value from the string using a regular expression. For example, for the string “Duration of residence <10”, you can use the regular expression “\d+” to extract the number 10.
Convert the extracted numerical value to an integer using the CInt function.
Check if the integer is less than 10 using a simple If condition. If it is less than 10, return true, else return false.
Similarly, to check if the age is between 60-64 or greater than 65, you can use the following steps:
Use the Matches activity to extract the numerical value from the string using a regular expression. For example, for the string “Age >65”, you can use the regular expression “\d+” to extract the number 65.
Convert the extracted numerical value to an integer using the CInt function.
Check if the integer is between 60-64 or greater than 65 using a simple If condition. If it is, return true, else return false.
Do you want to validate if your number n is greater 10 ? since the image is also showing up as >10 ? Or is the >10 Check a constant check ?
Also for the other case, the age number let’s say ageVar, do you want to check if this number is according to the criteria in the image i.e 50-54 ? Or is it again a constant check as mentioned 60-64 or >65 ?
Yes I want to validate that it is greater than 10.
The second check is constant like if the ageVar get the string 50-54 we must have a mechanism by which we can check that ageVar is either between 60-64 or greater than 65.