I tried to check if string contains some patterns string For example: '4+3+6**4'.
I want replace the pattern ** to pow(x,y).
so i want the string will be 4+3+pow(6,4).
i want to know if there any way by 'Regex'.
trt.
Just capture the number which exists before and after to ** along with the match ** and then replace the match with pwo($1,$2) .
Regex.Replace(string, @"(\d+)\*\*(\d+)", "pwo($1,$2)");
(\d+)\*{2}(\d+)
You can use this.Replace by pow($1,$2).See demo.Use verbatim mode @.
pwo, do you meanpow?pow(6,4)so that the output is4+3+1296, or just leave it as a string?