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.
精彩评论