Splitting string doesn't work as expected

Hello there, I want to split a String, the string is the following:

ExtractedText = “82 Habitaciones privadas”
totalCuartos = ExtractedText.Split(" "c).First

I know that totalCuartos gives only the number. But when debugging it throws an error, because it doesn’t split the space between the number and the string, just the last one. I tried this in the immediate panel

image

I copied, pasted the symbol at position 2, but now doesn’t split last space
As you can see, this doesn’t make any sense, unless the spaces are different, but I don’t know such thing. How could I split all the string?

Thanks in advance!!

Hi

There might be some whitespace except character code 0x20.
Can you try the following expression?

System.Text.RegularExpressions.Regex.Split(yourString,"\s+").First()

Regards,

@Dev_Dav - if you have notepad++ you can check the HEX value of that character to make sure where it is x20 …

image

Hi there!
That actually worked, but using RegEx Wizard with the (\s)+ expression. I don’t know how to execute that code in the actual workflow, but many thanks!!

image

I do have notepad++ but I don’t know how to do that :frowning: sorry

Hi,

We can use it with Assign activity as the following, FYI.

img20210907-5

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.