Find and Replace Character

1258
5
10-25-2017 09:26 PM
DanielMcIlroy
Occasional Contributor

Hi All,

 

Interesting question, I need to generate a filename by concatenating a series of values from the survey form.

 

One of these values has been changed from an integer to a decimal field, meaning that decimal points are now an issue. The user would like to replace the "." with a "p", however I am unsure how to make this happen as a calculate in S123. Is it even possible?

 

Help would be greatly appreciated.

 

Cheers

Dan

0 Kudos
5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Dan,

There isn't a function to find/replace text that are in arbitrary positions.  In your case, there is a special way to work around since we can get the length of the integer portion via type conversion and then use the substr() function to extract to the left and right of the decimal; for a decimal question called d1:

concat(substr(string(${d1}), 0, string-length(int(${d1}))), "p", substr(string(${d1}), string-length(int(${d1}))+1, string-length(${d1})))

DanielMcIlroy
Occasional Contributor

Thank you very much for that James, that has worked perfectly! Really appreciate your help (and quick response), helped me out big time.

0 Kudos
KassandraRodriguez
Occasional Contributor

Hi there, Is Find and replace available yet?

0 Kudos
Philip-Wilson
Esri Frequent Contributor

Hi Kassandra,

No, this is not possible in Survey123 in a calculate question, the best workaround is as James describes above.

Phil.

0 Kudos
DelaereMickael
Occasional Contributor II

Hello,

does the Find and replace function exist now?