cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Matching Host Names with Regex

DanielS
DynaMight Leader
DynaMight Leader

Hi community, I wrote the following Regex to match either hostname formats:

 

(?:ocp-p[a-zA-Z]-a\d{0,2}|worker-\d{0,2}\.ocp4-re)\.cloud\.com

 

The hostname are dynamically created.

I've check the rule on Regex 101 and matches everything as expected, but when I go to Dynatrace and hit preview only matches example 1 and 4. What I'm doing wrong?

 

worker-10.ocp4-re.cloud.com
ocp-pe-a2.cloud.com
ocp-pe-a42.cloud.com
worker-0.ocp4-re.cloud.com

 

Thanks in advance.

 

The true delight is in the finding out rather than in the knowing.
8 REPLIES 8

Babar_Qayyum
DynaMight Guru
DynaMight Guru

Hello @DanielS 

Please try the following:

(?:.*cloud.com)

Regards,

Babar

thanks for your answer.

The true delight is in the finding out rather than in the knowing.

ChadTurner
DynaMight Legend
DynaMight Legend

I'd recommend using what @Babar_Qayyum supplied, if that still fails (which i dont expect) then maybe make 4 rules, one for each line item to ensure they are working correctly. 

-Chad

DanielS
DynaMight Leader
DynaMight Leader

Thanks, finally instead of doing one rule, I made one for 1 and 4 and other one for the 2,3. It's not what I wanted, but the field is limited to 80 chars, so If in a future I add more examples it would be easier to maintain.

The true delight is in the finding out rather than in the knowing.

great to hear, but yes I've run into issues too with character limits for regex, but still cut down on the overall rules. glad it worked 

Maybe toss in a RFE for that limit to be raised. 

-Chad

Good Idea, I've done a request and wait if it accepted. Thanks for your answers.

The true delight is in the finding out rather than in the knowing.

toss along the link and ill up vote it 

-Chad

https://community.dynatrace.com/t5/Dynatrace-product-ideas/RFE-Raise-Regex-Field-Limit/idi-p/163183

 

Done

The true delight is in the finding out rather than in the knowing.

Featured Posts