Trust ID PBCEX logo 300x102

String Replace Character

4 years 3 weeks ago 4 years 3 weeks ago by Ingo Sterthaus.
Ingo Sterthaus
Expert Boarder
Expert Boarder
Posts: 125
More
Topic Author
String Replace Character #6260
Hi Guys,

i've got a database field to encode and there is a character in the encoding string that should be replaced by another character. Do you know if there is something like a string_replace function?

RAW Data	
Character: =
Data: 0B9276004690120142006=00000000000000000F
Final Encode Data
Character: D
Data: 0B9276004690120142006D00000000000000000F

Best regards

Ingo

We bring CardExchange to its limits. You can ask Rutger and Sergio. ;-)
4 years 3 weeks ago
Craig Bechelli
Administrator
Administrator
Posts: 624
More
String Replace Character #6261
Hi Ingo,

If you set the field to be a script and enter the following:

str.replace(old, new)

This should then create 3 variables which you can set as follows:

str - Linked to database field
old - =
new - D

Now each occurrence of the = character should be replaced with a D, if you need to change the characters just change the value set for the variable.

Regards,
Craig

Craig Bechelli
CardExchange Solutions Support Team

"If you define the problem correctly, you almost have the solution." (Steve Jobs)
The following user(s) said Thank You Ingo Sterthaus
4 years 1 week ago
Ingo Sterthaus
Expert Boarder
Expert Boarder
Posts: 125
More
Topic Author
String Replace Character #6267
Hi Craig,

thanks that works well! Instead of using three variables it is also possible to set the old and new character in quotes. Just for a better overview a short summary:

str.replace("searchtext", "replacetext")

str : variable linked to the database field with the content to search and replace	

or

str.replace(old, new)

str : variable linked to the database field with the content to search and replace
old : variable as static text with the character or string to search for
new : variable as static text with charachter or string to replace 

Regards Ingo

We bring CardExchange to its limits. You can ask Rutger and Sergio. ;-)
The following user(s) said Thank You Craig Bechelli
×

Notice

The forum is in read only mode.