I have a string which is a sentence or two long (more than one word). In that sentence there will be a hash-tagged word e.g. #word. This needs to be replaced with *word*.
If the sentence is:
Today the weather is very nice #sun
It should become:
Today the weather is very nice *sun*
How would I go about doing this?
You could do a regular expression, like this:
var output = Regex.Replace(input, @"#(\w+)", "*$1*");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With