c# - Regular expression find and replace to wrap tags -


does know how use regex find , replace word with

<b>[keyword]</b> 

i tried use regex.replace() seems support direct replacement instead of appending <b></b> @ begin , last of keyword.

example:

hello world! 

keyword:

hello 

output:

<b>hello</b> world! 

you may try this:

using system; using system.text.regularexpressions;  class program {     static void main(string[] args)     {         string             input = "hello world!",             keyword = "hello";          var result = regex             .replace(input, keyword, m =>                  string.format("<b>{0}</b>", m.value));         console.writeline(result);     } } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -