Trying to parse user provided content in a table - example
||Property||Value||
|prop1|Value 1|
|prop2|value 2|
eg
||Property||Value||
|Date|2025-02-08|
|Day|Saturday|
|Year|2025|
|Month|February|
|Day|8|
I can use the indexOf to find the property "cells" looking for a way to find the first pipe "|" after "|prop1|"... the first pipe after "|prop2|" etc.
Where are you trying to do this?
For example, if this is with an automation rule you could try using the match() function with a regular expression:
Kind regards,
Bill
Thanks for the suggestion - looks promising. Will give it a try and update here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy Can you help with syntax to access the array elements? I thought I would add the array index in brackets (e.g., [0]), but am getting the following error:
Error rendering smart-values when executing this rule:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For accessing list elements in a rule, use the 0-based get() function:
{{issue.description.match(".*(|).*").get(0)}}
or use the first function to get the 0th one:
{{issue.description.match(".*(|).*").first}}
Wouldn't both of those just return the pipe character?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy - First and foremost thank you for pointing me in the right direction!
Q: Wouldn't both of those just return the pipe character?
A: Correct. I am looking for the contents within the table cells, which I am able to do by replacing match with split.
Updated Description (using single pipes for table headers)
|Property|Value|
|Date|2025-02-08|
|Day|Saturday|
|Year|2025|
|Month|February|
|Day|8|
Here's the output:
issue.description.split("|").get(0) = ' ' issue.description.split("|").get(1) = 'Property' issue.description.split("|").get(2) = 'Value' issue.description.split("|").get(3) = ' ' issue.description.split("|").get(4) = 'Date' issue.description.split("|").get(5) = '2025-02-08' issue.description.split("|").get(6) = ' ' issue.description.split("|").get(7) = 'Day' issue.description.split("|").get(8) = 'Saturday' issue.description.split("|").get(9) = ' ' issue.description.split("|").get(10) = 'Year'
Not sure why the first array item is empty. Items 3, 6, and 9 are new line characters
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The first is probably null because the leading character is a delimiter (i.e., pipe).
And, newlines can be problematic for scenarios like this, more so when using match(). If they are causing trouble, perhaps replace them with another known / ignored delimiter. I often use a double-tilde such as ~~ to get them out of the way, but replaceable back to newlines, as needed, later.
Just to confirm, do you have what you need now to parse the data?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes confirmed. Thanks again for pointing me in the right direction!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.