Replace Special Character

Hello all,

i have a problem concerning a special character in a field I scrape from a webpage.

The field looks like that:
image

I only want the number, so I replace the other characters:
image

Unfortunately, I cant assign the processed number to an INT32-Field, because the process says that its in the wrong format. After copying the error message in a word, I saw that there is a special character in between:
image

I want to replace the °, but if I copy the sign from word into my process, I only get an empty space. Also if I want to replace the ° with the character on my keyboard it doesn`t work.

Any suggestions? Im grateful for your help!

Cheers, Fabian

have a look here:
grafik

1 Like

Hi @FAB

Can you share the Input and output string

You can achieve via Regex expression

System.Text.RegularExpressions.Regex.Replace(Inputstring, “[^\w\-]”, “”).ToString

Regards
Gokul

1 Like

About the kilometers… also have a look on Regex like
grafik
then you can post process the string further

1 Like

Thx, but doesn`t work. I also used the # to see if it puts it in my number, unfortunately the result is still the same as before.

image

as also shown in the screenshot was the usage of ASC method.

We can use this method, when passing the particular unknown char to it by using the position index of it within the string.

However we would recommend

  • start analysis on the webpage and check for any entities
  • check the result when grabbed from there
  • do analysis as mentioned above
  • avoid too much corrections in one go

Currently we also cannot match 87°097 screenshot to your reported 182 800 km case. Maybe you can elaborate on it

1 Like

You are right Peter, thank you for your help! I will have a look on your suggestions!

Unfortunately the REGEX Expression doesn`t help. My Expression in the Assign activity KilometersRegex:

System.Text.RegularExpressions.Regex.Replace(KilometersReady, “[^\w\-]”, “”).ToString

The input from “KilometersReady” :

“message”: “87 097 km”,
“level”: “Trace”,
“logType”: “User”,

The output after Kilometers Regex:
“message”: “87 097 km”,
“level”: “Trace”,
“logType”: “User”

Can you share the Input and Output @FAB

better input output samples would help us. Also have a look on this

grafik


last line is about to extract a block as short as possible and extract from this only the digits

1 Like

@FAB We can ignore these type of characters and get only numbers separated by it and finally concat the entire value

Capture

This way in future if you get any character other than this, that can be simply handled with the above logic

Please find the workflow attached

Regex.zip (2.3 KB)

1 Like

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