Splitting a pipe delimited field

Shawn Ebeyer asked on September 26, 2016 20:02

Hi,

I'm having some issues with syntax and would love some guidance.

I have a pipe delimited field 'word1|word2' and I need to split at the pipe to display the two words. I 'm using a text/xml transformation so am guessing I will need to use {% ... %}

Thanks in advance,

Shawn

Recent Answers


Jim Spillane answered on September 26, 2016 20:47

Hi Shawn.

Try

{% FieldName.Split("|")[0]) %}
{% FieldName.Split("|")[1]) %}
2 votesVote for this answer Mark as a Correct answer

Shawn Ebeyer answered on September 26, 2016 21:11

Hi Jim,

Thanks for the reply - but unfortunately this is not working. Maybe I should have mentioned that the field I am trying to split is a related page field if that makes sense?

Thanks,

Shawn

0 votesVote for this answer Mark as a Correct answer

Laura Frese answered on September 27, 2016 00:12

{% FieldName.ToString().Split("|")[0] %}

Sometimes I just want to add commas to replace the pipe

{% FieldName.ToString().Replace("|",", ") %}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.