I need to check the contents of the cell in the table to match some parameters. For example: “space” + “some word or number” + “space”
I guess I should to use this feature, but I can’t understand how
Please help me with this case or tell me where to find the information I need
Google “regex syntax” to learn how to create text matching and then place the regex string in the Value field…
Good tool for regex dev work.
Allows you to save and share your regexes too:
Russ Thomas said:
Good tool for regex dev work.
Allows you to save and share your regexes too:
Thank you for the answers, but why it does not work in Katalon Studio


Katalon’s regexes are problematic. (Kazarayum posted a reasoned out answer some time ago but I can’t find it.) Whenever I want to verify regex, I use JavaScript.
To create regex expressions, I use tools like the following:
http://www.rexegg.com/regex-quickstart.html
To verify regex expressions, I use tools like the following:
I haven’t tried to use the tools with different character sets, as the above example shows…
Could the character set be causing the issue?
I suppose all of Test Objects in Katalon Studio with Condition “matches regex” will not work properly.
Please have a look at http://forum.katalon.com/discussion/7680/test-object-with-xpath-selector-using-matches-function-never-works?new=1
Gregory,
I think you should not use Test Object with Condition “matches regex”.
But you have alternative way of checking texts in a Web page with regular expression supported by the java.util.regex.Pattern and java.util.regex.Matcher class. See the following code as a test case:
import java.util.regex.Matcher
import java.util.regex.Pattern
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser('')
WebUI.setViewPortSize(703, 347)
WebUI.navigateToUrl('http://demoaut-mimic.kazurayam.com/7609_testbed.html')
Pattern pattern = Pattern.compile(/[\p{InCyrillic}\s]+/)
TestObject testObject = new TestObject('myTestObject')
testObject.addProperty('xpath', ConditionType.EQUALS, '//td')
List<WebElement> tds = WebUiCommonHelper.findWebElements(testObject, 10)
for (WebElement td : tds) {
String content = td.getText()
//WebUI.comment(">>> content : ${content}")
Matcher matcher = pattern.matcher(content)
if (matcher.find()) {
WebUI.comment(">>> here is cyrillic letters : ${content}")
} WebUI.verifyMatch(content, '[\\w\\p{InCyrillic}\\d\\s]+', true, FailureHandling.CONTINUE_ON_FAILURE)
}
WebUI.closeBrowser()
You can try any Regular expression (such as [\p{InCyrillic}\s]+ as above) as described in https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
You can see the target page here:
http://demoaut-mimic.kazurayam.com/7609_testbed.html
When I ran the test case, I got the following message in the log:
...
[INFO] - >>> here is cyrillic letters : ИВАН
...
[PASSED] - Actual text 'ИВАН' and expected text '[\w\p{InCyrillic}\d\s]+' are matched using regular expression...
[INFO] - >>> here is cyrillic letters : ИВАНОВ ИВАН 123
...
[PASSED] - Actual text 'ИВАНОВ ИВАН 123' and expected text '[\w\p{InCyrillic}\d\s]+' are matched using regular expression...
[PASSED] - Actual text 'IVAN' and expected text '[\w\p{InCyrillic}\d\s]+' are matched using regular expression...[PASSED] - Actual text 'IVANOV IVAN 123' and expected text '[\w\p{InCyrillic}\d\s]+' are matched using regular expression...