# How to use the parse command when possible empty value between separators

**URL:** <https://community.dynatrace.com/t/how-to-use-the-parse-command-when-possible-empty-value-between-separators/48397>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [October 17, 2024, 8:52pm UTC](https://community.dynatrace.com/t/how-to-use-the-parse-command-when-possible-empty-value-between-separators/48397 "2024-10-17T20:52:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agravier](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/agravier/32/29303_2.png) [@agravier](https://community.dynatrace.com/u/agravier)\
**Post date:** [October 17, 2024, 8:52pm UTC](https://community.dynatrace.com/t/how-to-use-the-parse-command-when-possible-empty-value-between-separators/48397/1 "2024-10-17T20:52:47Z")

</div>

Hello,

I have to extract data from a line of log using a specific format :

provider;id;name;bu;domaine;app;amount;env

My DQL request below works when there is no empty value on my record :

data record(a = “GCP;128773868256;ICDO-KISS;PLFCHAP;PLATE;MYVALUE;DEV;5”)  
| parse a, (“LD:provider ‘;’ LD:id ‘;’ LD:name ‘;’ LD:bu ‘;’ LD:domaine ‘;’ LD:app ‘;’ LD:amount ‘;’ LD:env”)

 ![AurelienGravier_0-1729196726574.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/453b73a75ee02c08ca35a3216ff14b01c0336635.png)

But it doesn’t work if there is an empty value :

data record(a = “GCP;128773868256;ICDO-KISS;PLFCHAP;PLATE\*\*;;\*\*DEV;5”)  
| parse a, (“LD:provider ‘;’ LD:id ‘;’ LD:name ‘;’ LD:bu ‘;’ LD:domaine ‘;’ LD:app ‘;’ LD:amount ‘;’ LD:env”)

 ![AurelienGravier_2-1729197388820.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/b/6bb0a914d25070670a5ddfd856cbbfd253534815.png)

How to manage empty value on parse command please ?

Thank you.

Regards Aurelien

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [October 18, 2024, 5:10am UTC](https://community.dynatrace.com/t/how-to-use-the-parse-command-when-possible-empty-value-between-separators/48397/2 "2024-10-18T05:10:39Z")

</div>

Hey&nbsp;[@AurelienGravier](https://community.dynatrace.com/user/44995)

For your specific example you can use “Optional Modifier” as documented [here](https://docs.dynatrace.com/docs/platform/grail/dynatrace-pattern-language/log-processing-modifiers#optional-modifier). Using your query, that would look something like the below:

```markup
data record(a = "GCP;128773868256;ICDO-KISS;PLFCHAP;PLATE;;DEV;5")
| parse a, ("WORD:provider ';' WORD:id ';' LD:name ';' WORD:bu ';' WORD:domaine ';' WORD?:app ';' WORD:amount ';' WORD:env")

```

One thing to note though is that I have change the above to use WORD instead of LD. This is because LD matches to semicolons which means if the value in-between is missing it will just match to the second semicolon and the parsing will fail. For the given example you could use WORD for all fields except for name. For name I cam up with a character class that looks like&nbsp;[0-9a-zA-Z-] and the use of which is documented [here](https://docs.dynatrace.com/docs/shortlink/dpl-lines-strings#character-group) but the character class doesn’t seem to work. Testing the character class in regex works but within the DQL parse command it doesn’t seem to work even though it’s supposed to be supported, potentially it requires some more tweaking.

Hope the above helps!

---

<div class="post-metadata">

**Author:** ![agravier](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/agravier/32/29303_2.png) [@agravier](https://community.dynatrace.com/u/agravier)\
**Post date:** [October 18, 2024, 7:26am UTC](https://community.dynatrace.com/t/how-to-use-the-parse-command-when-possible-empty-value-between-separators/48397/3 "2024-10-18T07:26:22Z")

</div>

Hello&nbsp;[@Fin\_Ubels](https://community.dynatrace.com/user/47376)&nbsp;,

Thank you for your help, I tried “Optional Modifier” without success because I didn’t try to change the LD type.

FYI, with a character group&nbsp;[character-group](https://docs.dynatrace.com/docs/shortlink/dpl-lines-strings#character-group)&nbsp;the name field is parsed with success :

data record(a = “GCP;128773868256;;PLFCHAP;PLATE;;DEV;5”)  
| parse a, (“WORD:provider ‘;’ WORD:id ‘;’ **[0-9a-zA-Z-]{1,100}?**:name ‘;’ WORD:bu ‘;’ WORD:domaine ‘;’ WORD?:app ‘;’ WORD:amount ‘;’ WORD:env”)

 ![AurelienGravier_0-1729236123232.png](https://global.discourse-cdn.com/dynatrace/original/2X/3/3bb0488e81dd357898a0aced143ed5e1daa9b2a6.png)

Regards Aurélien
