0

I need help with regular expressions. I have some queues in the rabbitMQ, about 1000:

ha-collector-data-test2
ha-collector-data-1434
ha-collector-data-45-test3
ha-collector-data-terty4
ha-collector-data-341
etc.

And I need to filter these queues. For example:

FILTER='[{"name": "ha-collector-data-test2"}, {"name": "ha-collector-data-1434"}, {"name": "ha-collector-data-45-test3"}, {"name": "ha-collector-data-terty4"} ]'

To describe every queue by a separate name is difficult

Which regular expression should I use for my queues which have same start names? I used this but it is wrong:

FILTER='[{"name": "ha-collector-data-*"} ]'
FILTER='[{"name": "ha-collector-data-[a-z]"} ]'
1
  • 1
    I suggest using a site like regex101.com to test, observe and learn how the regex matching is (not) being performed.
    – parkamark
    Feb 13 '20 at 8:47
0

The following pattern should match your examples:

FILTER='[{"name": "ha-collector-data-.*"} ]'

This specifies: Match every character (= '.') zero or more times (= '*')

Your both filters dont work because:

1) FILTER='[{"name": "ha-collector-data-*"} ]'
'*' matches the preceding character zero or more times. Since the preceding char is - 
this rule matches something like ha-collector-data-- 


2) FILTER='[{"name": "ha-collector-data-[a-z]"} ]'
This filter doesn't match the strings that start with numbers after '-' and 
furthermore it matches the next char only.
3
  • Hi. Thank you for reply. But i think my problem more concerns rabbitMQ api and i should find documentation for that.
    – perrfect
    Feb 13 '20 at 12:41
  • Hi. Ok sorry so i got your problem wrong :) Feb 13 '20 at 13:20
  • But, maybe, do you want which regex will be right? I do FILTER='{"name": "ha-collector-data-.[a-zA-Z0-9]{1,100}"}'. But it is wrong too(
    – perrfect
    Feb 13 '20 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.