Skip to main content
Solved

RegEx match


Forum|alt.badge.img+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?

 

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
Did this topic help answer your question?

4 replies

LoganPrice
Most Valuable Pathfinder
Forum|alt.badge.img+12
  • Most Valuable Pathfinder
  • 77 replies
  • January 17, 2024

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


Forum|alt.badge.img+8
  • Author
  • Navigator | Tier 3
  • 61 replies
  • January 17, 2024

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


Forum|alt.badge.img+8
  • Author
  • Navigator | Tier 3
  • 61 replies
  • Answer
  • January 19, 2024

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


Forum|alt.badge.img+5
  • Navigator | Tier 3
  • 14 replies
  • January 22, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings