Skip to main content
Solved

RegEx match

  • Jan 17, 2024 1:02 PM UTC
  • 4 replies
  • 1344 views

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?

 

Best answer by MichalTurek

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

View original

4 replies

LoganPrice
Most Valuable Pathfinder
Forum|alt.badge.img+4
  • Most Valuable Pathfinder
  • Jan 17, 2024 4:41 PM UTC

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


  • Author
  • Navigator | Tier 3
  • Jan 17, 2024 8:51 PM UTC

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


  • Author
  • Navigator | Tier 3
  • Answer
  • Jan 19, 2024 11:09 AM UTC

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


  • Navigator | Tier 3
  • Jan 22, 2024 1:54 PM UTC

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