Click here to Skip to main content
14,870,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am doing some string manupulations in my project. I am using the regex. replace method to replace the strings. But it replaces all occurances whereever the search string found.

Let us assume the input string as "ab abcd abcde" and search string as "ab" and the replace string as "XY".

If I use regex.replace("ab abcd abcde","ab","XY",RegexOptions.IgnoreCase), the output is found as below.

"XY XYcd XYcde"

But I am expecting the output as "XY abcd abcde". I mean the string should replace by using whole word search.

Can anyone help me on this.

Thanks,
Sivakumar.M.
Posted

1 solution

Your regex pattern is wrong. Post it so we can see what you did.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900