How to replace single and double quotes in a string

Hi Guys, I have below requirement, Can you please help me on the following?

Lets say I have string str1= ab’c"d

My string is having both double and single quotes and I want to replace both the quotes with space or anything else, but I am struggling to do it.

Thanks in Advance! :grinning:

Hi @shreyash_shirbhate

Have you tried using replace activity or method?

Hi @Sudharsan_Ka ,

I have tried with replace activity but I am not able to do it for the both the quotes(Single and Double quotes)!
Suggest me if you have anything!

You can try that with regex?

@Sudharsan_Ka , Can you provide me the sample workflow! Thanks in Advance!

@shreyash_shirbhate - Here you go…

image

My Strinput value is "ab’c""d" - Since you have double quotes in the string values, you have to add it twice to include it…Same logic to be applied while replacing also.

Since I have used it twice, In the immediate panel it will show as \" , meaning I have escaped it…

Hope this helps…

1 Like

Hey @prasath17,

Thanks for your input.

Lets say, my StrInput is ab"c

So in this case it will not work right? I need solution for above string. (ab"c)

" Lets say I have string str1= ab’c"d - This is the input you gave in your query right? So I have provided solution for that.

If you string is ab"c - Then simple just use only one replace…You should be good…

image

May I ask, why you didn’t mentioned this in your query? “My string is having both double and single quotes and I want to replace both the quotes with space or anything else” - This is your original requirement.

Hey Thanks @prasath17,

I got it now, Sorry I missed to give the single quotation mark in earlier post!

Thanks It is working for me!

ReplaceString.Replace(“'”,“”).Replace(“”“”,“”).ToString

1 Like

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