Handling "\n" in Replace function

151 Views Asked by At

I have used GetText on an area of screen text and it has returned values separated by "\n". This is perfectly fine as there are line-breaks in the text and actually is exactly what I wanted, however, I want to convert the string into a list, splitting on the "\n".

My issue is that I get the following error from this line of foce:

put text split by "\\n" into itemList

Sensetalk compiler exception: syntax error - cant understand "n" at line.....

I initially thought there was a delimiting issue, having originally tried to split on "\n" so I switched to "\n" but the same error occurs..

How can you use the split function when there are escape sequences in the string?

many thanks

1

There are 1 best solutions below

0
DeepPurpleActual On

Depending on how OCR is reading this in, one of the predefined variables should be equivalent to your \n. I would expect this to work:

put text split by newline into itemList

You can find out more about predefined variables in SenseTalk here: https://docs.eggplantsoftware.com/studio/stk-restricted-words/#predefined-variables