Facing issue in replace function

I am facing problem while replace function

var myString = “The “mysteing” is”

My request is myString.Replace(“”“mysteing”“”,“abc”) will return me “The abc is”

myString.Replace(“““mystring”””,“XYZ”), it stills returns me “The “mystring” is” which is wrong. Expectation is it should return “The abc is”

Hi @Mahera_Khan

try below step it will work.

myString = “The ‘mysteing’ is” // use single quote ‘mysteing’ inside " "

myString.Replace(“‘mysteing’”, “abc”) // use single quote ‘mysteing’ inside" "

The result you will get is–> The abc is

Please mark it solution if your issue resolved..

Use below:
myString2.Replace(ChrW(8220)+“mystring”+ChrW(8221),“xyz”)

Hi @Mahera_Khan

Can you share the screenshot?

Another approach

Or

Input.Replace("""mysteing""","abc")

Input.Replace("""mysteing""","xyz")

Regards,

Hello @Mahera_Khan,

You can me use of regular expression to achieve the goal.

myString = System.Text.RegularExpressions.Regex.Replace(myString, ““[^”]*””, “abc”)

Marks this as solution if it helps.

Regards,
Bharat

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