Skip to end of metadata
Go to start of metadata


Filter out the last part of the URL I get back from the "WebUI.getURL()" function


Use Pattern and Matcher classes from java.util.regex package.

import java.util.regex.Matcher
import java.util.regex.Pattern
import com.kms.katalon.core.util.KeywordUtil

String url = ''
Pattern regexPat = Pattern.compile('(?:(\\w+)\\/$|(\\w+)\\?|(\\w+)$)')
Matcher mat = regexPat.matcher(url)

if(mat.find()) {
    String result =
    println result
else {
    KeywordUtil.markFailed('Substring not found.')

// pattern found:

Credit to Marek Melocik 

  • No labels