Get ready for BLACK FRIDAY shopping starting in

HTML5 Data Bindings Formatter Support Product Page

Answered

How can I replace special characters? Need to replace the vertical line

Asked 05 Feb 2014 03:35:28
1
has this question
05 Feb 2014 03:35:28 Steven Milo posted:
How can I replace special characters? Need to replace the vertical line " | " or the " ] ". I have tried html code for the key as well. Also changing it to string first.

Replies

Replied 07 Feb 2014 08:08:50
07 Feb 2014 08:08:50 Miroslav Zografski replied:
Hello Steven,
The Formatter has a replace filter under Text.

Regards.
Replied 07 Feb 2014 22:54:03
07 Feb 2014 22:54:03 Steven Milo replied:
Tried that. Look at this

Original format <td> Returning <br /> {{id}}</td>
Returns
Returning UA233[LAX-JFK]|UA314[JFK-LAX]

With replace text filter <td>Returning<br /> {{id.replace( "|", "Hello" )}}</td>

Returns
Returning
HelloUHelloAHello2Hello3Hello3Hello[HelloLHelloAHelloXHello-HelloJHelloFHelloKHello]Hello|HelloUHelloAHello3Hello1Hello4Hello[HelloJHelloFHelloKHello-HelloLHelloAHelloXHello]Hello

What I would ultimately like to have it read as
Inbound LAX-JFK UA233
Outbound JFK-LAX UA314

Am trying to split at the | and at the [ ] . the [ } work with html code, put the | vertical line does not. Same result on the vertical line with
HTML Entity (decimal) &#124;
HTML Entity (hex) &#x7c;

replaces the text at every character.


thanks
Replied 11 Feb 2014 07:21:11
11 Feb 2014 07:21:11 Steven Milo replied:
Tried that. Look at this

Original format <td> Returning <br /> {{id}}</td>
Returns
Returning UA233[LAX-JFK]|UA314[JFK-LAX]

With replace text filter <td>Returning<br /> {{id.replace( "|", "Hello" )}}</td>

Returns
Returning
HelloUHelloAHello2Hello3Hello3Hello[HelloLHelloAHelloXHello-HelloJHelloFHelloKHello]Hello|HelloUHelloAHello3Hello1Hello4Hello[HelloJHelloFHelloKHello-HelloLHelloAHelloXHello]Hello

What I would ultimately like to have it read as
Inbound LAX-JFK UA233
Outbound JFK-LAX UA314

Am trying to split at the | and at the [ ] . the [ } work with html code, put the | vertical line does not. Same result on the vertical line with
HTML Entity (decimal) &#124;
HTML Entity (hex) &#x7c;

replaces the text at every character.


thanks
Replied 11 Feb 2014 09:07:39
11 Feb 2014 09:07:39 Miroslav Zografski replied:
Hello Steven

here try this:

Inbound {{id.split( "|" )[0].split("[")[1].replace("]","")}} {{id.split( "|" )[0].split("[")[0]}}[br]
	 Outbound {{id.split( "|" )[1].split("[")[1].replace("]","")}} {{id.split( "|" )[0].split("[")[0]}}


here you can see the results:
79.124.72.94/testOPE/flights.php
Regards.
Replied 11 Feb 2014 14:58:46
11 Feb 2014 14:58:46 Steven Milo replied:
Yours seems to work. I get a blank page. Not sure why.

testing.getmi.com/timehelp.html
Replied 11 Feb 2014 18:05:34
11 Feb 2014 18:05:34 Steven Milo replied:
Think the error happens when there is more than 2 flights. Not sure.
This reply was removed on 2/11/2014 6:05:59 PM.
See the changelog
Replied 12 Feb 2014 08:04:19
12 Feb 2014 08:04:19 Miroslav Zografski replied:
OK, Steven,

You miss something, or maybe it is something we lack, but when you split like:
{{id.split("|") 

this results in an array, so if you like to continue working with particular entry in that array you need to define it like:
{{id.split("|")[0]}} 
which will output the first entry in the array ( in your case - the inbound). Then you can go further and apply the second split. This time on the second entry in the array resulted from the second split - the airport:
{{id.split("|")[0].split("[")[1].replace("]","")}} 
outputs: LAX-JFK
then the flight number:
{{id.split("|")[0].split("[")[0].replace("]","")}}
outputs: UA233
and so on and so forth.

Regards,
Replied 12 Feb 2014 15:15:38
12 Feb 2014 15:15:38 Steven Milo replied:
got it. thank you

Reply to this topic