-1

I have a regex expression which checks for the valid date and timezone format but when I tried to use it in Katalon, I get unexpected errors about using the slases:

^\d\d([-/])\d\d\1\d{4} \d\d:\d\d [AP]M ET$

Here's an example of the regex that seems to be working in here: https://regex101.com/r/nZC9PB/1

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
iDan
  • 25
  • 3
  • It is not clear what the exact issue you got. Please also share the relevant docs, else, please file a support request in the tool support. SO is a site for programming issues, not 3rd party software issues. – Wiktor Stribiżew Jan 25 '23 at 08:42

2 Answers2

2

The regex expression by user should work well in some languages / platform, but in order to make it accurate to Katalon, we should use escaped character '' before '/' in '[-/]'. So that Katalon Studio can understand the regex expression correctly.

The correct regex expression should be:

^\d\d([-\/])\d\d\1\d{4} \d\d:\d\d [AP]M ET$

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
1

For doublequoted string in groovy you have to escape every \ and $ --> \\ and \$

But there is a slashy string in groovy where you need to escape only slash symbol / --> \/

https://groovy-lang.org/syntax.html#_slashy_string

def re = /^\d\d([-\/])\d\d\1\d{4} \d\d:\d\d [AP]M ET$/
assert "06-01-2023 11:59 PM ET" =~ re

"Ok"
daggett
  • 26,404
  • 3
  • 40
  • 56