DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Return True if Pattern is found anywhere within Text - Help

badgerfifteen
Organizer

Hi,

I am formulating a DPL command to return true if a pattern such as a credit card format/number exists anywhere within a piece of text. 

For example....

data record(a = "378282246310005")
| parse a, """CREDITCARD:cc"""
| fieldsAdd hasCreditCard = isNotNull(cc)

 ... this would return true, but the minute I add anything before or after it will return false. Any ideas on how to detect that pattern anywhere within a piece of text, or a log? Which is where this code/function is going to be used. 

2 REPLIES 2

Julius_Loman
DynaMight Legend
DynaMight Legend

@badgerfifteen I think you just have your parse command incorrect, and you need to add LD* (Line data, optional):

data record(a = "x378282246310005")
| parse a, """LD* CREDITCARD:cc"""
| fieldsAdd hasCreditCard = isNotNull(cc)

 

Dynatrace Ambassador | Alanata a.s., Slovakia, Dynatrace Master Partner

Thanks, this works! I used this and changed and changed LD to DATA to account for log entries or pieces of text with new lines. 

Featured Posts