Expand my Community achievements bar.

SOLVED

Parsing Key Value Pairs

Avatar

Level 7

We have a flow that is parsing text from an Outlook Email using the HTML to Text parser which works fine, then taking that and using the Get Elements from Text module with Key Value Pairs.  This is spliiting up the body correctly except in cases where the title uses special characters.  The item below would read in as Multidisciplinary Center and drop everyting after the special character occurs.  What do I need to do to get it to read the special characters? Multidisciplinary Center (MDC) Medical History

 

Stacey_Robertson_0-1747152076188.png

 

Item Name: Multidisciplinary Center (MDC) Medical History

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Stacey_Robertson 
I'd create a ticket - that seems off they chop off the value portion due to a "("

 

Meantime, roll your own with a regular expression (Match Pattern module)

IF all your key-value pairs are on separate lines: 

^(\w[^\n\r:]+:\w.+?)$

[ \w = a-z and A-Z and 0-9 and _ (underscore) ]

 

That'll spit out all the matches as separate bundles.

Make sure to check Global Match and Multi-line boxes

 

In English, this looks for lines that

  • start with one char that is  a-z or A-Z or 0-9 or _
  • and followed by anything that is not a line feed, carriage return or ":" 
  • followed by colon (key:val separator)
  • followed by one char that is  a-z or A-Z or 0-9 or _
  • and followed by any character until end of line

[ Note in theory we shouldn't need to check for preceding line feeds and carriage returns but apparently this module also has a bug! ]

 

This allows for spaces and other "special" characters in key or value.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @Stacey_Robertson 
I'd create a ticket - that seems off they chop off the value portion due to a "("

 

Meantime, roll your own with a regular expression (Match Pattern module)

IF all your key-value pairs are on separate lines: 

^(\w[^\n\r:]+:\w.+?)$

[ \w = a-z and A-Z and 0-9 and _ (underscore) ]

 

That'll spit out all the matches as separate bundles.

Make sure to check Global Match and Multi-line boxes

 

In English, this looks for lines that

  • start with one char that is  a-z or A-Z or 0-9 or _
  • and followed by anything that is not a line feed, carriage return or ":" 
  • followed by colon (key:val separator)
  • followed by one char that is  a-z or A-Z or 0-9 or _
  • and followed by any character until end of line

[ Note in theory we shouldn't need to check for preceding line feeds and carriage returns but apparently this module also has a bug! ]

 

This allows for spaces and other "special" characters in key or value.