Skip to content

Regexp filter for message handler only match if message is 2 words #581

Answered by evgfilim1
100nandoo asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, @100nandoo. You can use this regexp for your handler: ^(\w+) (\w+)$

Explanation

  • ^ asserts the start of the line
  • (...) starts capturing group, so you can use the result of this capture later
  • \w is the same as [a-zA-Z0-9_]
    • [...] is a choice list, so it matches exactly one character from this list
    • [a-z] matches everything from a (ASCII codepoint 97) to z (ASCII codepoint 122)
    • [a-z0-9] helps you to match either [a-z] or [0-9]
    • so [a-zA-Z0-9_] is one of [a-z], [A-Z], [0-9] or _.
  • + is the same as {1,}
    • In common, {a,b} means "match previous expression (\w in this case) from a to b times"
    • If a is missing, it is considered equal 0
    • If b is missing, it is considered maximum
  • matches Sp…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@100nandoo
Comment options

@Olegt0rr
Comment options

@100nandoo
Comment options

Answer selected by Olegt0rr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants