How to replace string between two characters with Regex?


hello!

in application have string "sentence 1 rule id: whitespace_rule message: text..."

or string "sentence 2 rule id: morfologik_rule message: text..."

i want replace this: "rule id: some_rule message", want change first string to "sentence 1: text..." , second string to: "sentence 2: text..."

how using regex?

hi, try this:

string s = "sentence 1 rule id: whitespace_rule message: text..."; s = regex.replace(s, "rule id:[^:]*:", ":");



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

RFC_ERROR_SYSTEM_FAILURE with SAP ECC 6 Unicode

C# System.Data.Common DbCommand and getting Datasets from Oracle