开发者

Search subString in String which starts and ends with special character - C#

I want to search and replace substring in string w开发者_如何学Gohich starts and ends with special character.

string myString = "FIELD COMPARRISON SAME ROWîSTLîTHEATRE_CASEîCLIENT_IDî==î*EMERGENCY_CLINICAL_PRIORITY_LOCAL_CODE*í";

** I want to replace *EMERGENCY_CLINICAL_PRIORITY_LOCAL_CODE* with some other value **

Edit: Sorry my fault.

I want to replace EMERGENCY_CLINICAL_PRIORITY_LOCAL_CODE with some other value.

currently am using IndexOf to find first and second instance of * and then get the string with above indexes. How this can be achieved in RegEx?


char  marker = 'í';
Regex regex = new Regex (string.Format ("(?<={0})([^{0}]*)", marker));
regex.Replace (input, "replacement");

By the way, if marker ever changes, you may need to use Regex.Escape(marker) instead of marker in the string.Format.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜