Can anyone help me with how to collect the first two elements of an array in AJO (Handlebars.js) and store them in two different fields?
{% let demo = "1,903~19.03" %}
{% let array = split(demo, "~") %}
{% let val1 = array[0] %}
{% let val2 = array[1] %}
val1 :{{ val1 }}
val2: {{ val2 }}
I am using this, but I am getting an error.
Output:-
val1 :false
val2: false
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Some time I love regex to solve situations like this.
{% let demo = "1,903~19.03~1213" %}
{% let first = regexGroup(demo,"^([0-9,\\.]+)~([0-9,\\.]+)", 1) %}
{% let second = regexGroup(demo,"^([0-9,\\.]+)~([0-9,\\.]+)", 2) %}
{{first}}
{{second}}
~cheers,
NN
You can take a look at this related thread https://experienceleaguecommunities.adobe.com/t5/journey-optimizer-questions/get-last-item-of-a-list...
{% let demo = "1,903~19.03" %}
Second part
{% let idx = indexOf(demo,"~" ) + 1 %}
{%= substr(demo, idx, length(demo)) %}
First part
{% let idx = indexOf(demo,"~" ) %}
{%= substr(demo, 0, idx) %}
Some time I love regex to solve situations like this.
{% let demo = "1,903~19.03~1213" %}
{% let first = regexGroup(demo,"^([0-9,\\.]+)~([0-9,\\.]+)", 1) %}
{% let second = regexGroup(demo,"^([0-9,\\.]+)~([0-9,\\.]+)", 2) %}
{{first}}
{{second}}
~cheers,
NN
Hi @Ajo_WisdomChase,
Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!
Views
Replies
Total Likes
Views
Likes
Replies