Removing special character from the below Strings

324567-“Intersec Research and Technology Complex Eye Microsurgery n a Fyodorov Novosibirsk Branch

339733-A.O.U. Policlinico “G.Rodolico - San Marco”; Clinica Neurologica

203215-INTERNAL MEDICINE / DIVISIONHEMATOLOGY/ONCOLOGY

338983-XCEPHO - Centro de Estudos e Pesquisas em Hematologia e Oncologia

used below logic to remove but In case of " abc " string craetion is a problem also in case of " replacing single quote is a problem.

Sitename.Replace(“",” “).Replace(”/“,” “).Replace(”:“,” “).Replace(”*“,” “).Replace(”?“,” “).Replace(”<“,” “).Replace(”>“,” “).Replace(”|“,” “).Replace(”;“,” “).Replace(”'“,” “).Replace(“char(34)”,” “).Replace(”“”“,” ")

Hi,

you can try below query

Sitename.Replace(“'”, " “).Replace(”/“, " “).Replace(”:”, " “).Replace(”*“, " “).Replace(”?”, " “).Replace(”<“, " “).Replace(”>”, " “).Replace(”|“, " “).Replace(”;”, " “).Replace(”"“, " “).Replace(”""”, " ")

This should handle the single quote issue.

Hi @shashank_dullu ,

You can use following regex to replace special characters.

System.Text.RegularExpressions.Regex.Replace(variable, “[^a-z A-Z 0-9]”, “ ”)

System.Text.RegularExpressions.Regex.Replace(variable, “[^Characters you want keep as it is]”, “replacing character”)

I have already tried this. Throwing error At single Quote ("). that was the reason of choosing char (34) but the replace function wants string value in it

Hi @shashank_dullu

System.Text.RegularExpressions.Regex.Replace(Sitename.ToString,"([^a-zA-Z0-9\s])"," ")

Regards

Hi @shashank_dullu

Try this:

Input: "324567-“Intersec Research and Technology Complex Eye Microsurgery n a Fyodorov Novosibirsk Branch"
output: System.Text.RegularExpressions.Regex.Replace(Input,"[^\d A-Z a-z]","")

Hope it helps!!

Hi @Mohan_Reddy -
I have tried with Regular expression but is replacing lot of other things also because of which the meaning of the sentence is also changing .
only need to remove these special character.–> \ / : * ? " < > | ; ’
Also the Sentence is not getting converted in String properly because of multiple " in it

try this - 346677-XFundação Pio XII Hospital de Câncer de Barretos
in your logic name is getting changed

Hi @shashank_dullu

Try this:

System.Text.RegularExpressions.Regex.Replace(Input,"[^0-9 a-z A-Z À-Ö Ø-ö ø-ÿ]","")

Hope it helps!!

What is this ? How to Place my chacrter in this -
\ / : * ? " < > | ; ’

Hi @shashank_dullu

Please use the below expression in assign activity

System.Text.RegularExpressions.Regex.Replace(Sitename.ToString,"([~`!@#$%^&*()_+-={}|:"<>?\[\]\;',./])"," ")

regards

Hi @shashank_dullu ,

Try the following expression:

System.Text.RegularExpressions.Regex.Replace(variable, “[^a-zA-Z0-9\s-.]”, “ ”)

Hi @shashank_dullu

Try this please

[^0-9 a-z A-Z À-Ö Ø-ö ø-ÿ]

regards

How can we handle the below scenario in the inputs we are getting as we know it is not fixed the input the we are getting based on special charcters

Hi @shashank_dullu

if you are using the above in an assign activity then please store that data in a double quotes as it resembles the string data type.

Regards


While Putting the string into Quotes becuase of " ’ the string is not getting creating because of special characters

Hi @shashank_dullu

Can I know from where you will be getting those data?

Regards

This is the part of input that I will be receiving which is not in any fixed format . that is the overall reason of having this Replace .

324567-“Intersec Research and Technology Complex Eye Microsurgery n a Fyodorov Novosibirsk Branch

339733-A.O.U. Policlinico “G.Rodolico - San Marco”; Clinica Neurologica

203215-INTERNAL 'MEDICINE / DIVISIONHEMATOLOGY/ONCOLOGY

338983-XCEPHO - Centro de Estudos e Pesquisas em Hematologia e Oncologia

Hi @shashank_dullu

So when you are receiving that data you can directly store them in a string variable. So, after storing them in a variable use the regex directly on that variable.

Regards