Solved

RegEx match

  • 17 January 2024
  • 4 replies
  • 193 views

Badge +8

Hallo,

I want to conduct a condition of comparing a given sting to match a patter:

<exact 4 random digits></><exact 2 random digits> using a regex string:

\d{4}\/\d{2}.

F.i. string 2024/01 should be OK, but 202/01 or 2024/014 or 20243x/01 wouldn’t.

Using FIND action or REGEX tools doesn’t work as expected, any clues?

 

icon

Best answer by MichalTurek 19 January 2024, 12:09

View original

4 replies

Userlevel 3
Badge +9

Hi there @MichalTurek!

 

Can you please elaborate on where you are having trouble? Are you just trying to match the [4#]/[2#] sequence? Or are you trying to match the other three strings you provided as well?

Please provide as much detail as possible, and also include examples of what chracters will come before or after the string you provide (i.e. any white spaces or special characters) as this will help create a more reliable regex pattern.

As for your regex that you provided, I was able to get it to work in my bot editor:
 


 


Thanks,

Logan

Badge +8

Thanks @LoganPrice I supposedly got wrong the Find string action - I thought that the number value returning from it is 0 when no string is found and 1 when the match is present in the given string, is there another way to only detect if there’s a match or if it’s not,

greetings

Badge +8

Finally I managed to get it right:

Regex should be: ^\d{4}\/\d{2}$$

which narrows the search only for the exact number of characters,

then I useg a REGEX Tools: Get Number of Matches activity,

 

greetings MT

Badge +5

i`ve created a custom package to have a few more opctions to use with regex give it a try:

 

 

https://github.com/AA-360/A360_String/tree/main/build/libs

Reply