I have content stored as raw text in a database that I show in a HTML table on a web site. In the content people refer to numbers and i want to have those numbers automatically become links
For example, in a field I might have
This description is for driving a car. The manual refers to ABC:25920 and is very durable.
In this case above I want ABC:2590 to actually be an HTML link that translates to this HTML
<a href='www.mysite.com/parts/25920'>ABC:25920</a>
What is the best way of doing this. Some kind of find and replace? Is there some other pattern matching / regex solution here?
It’s not clear precisely what format the numbers have. If the rule is that anything which consists of capital letters, a colon, and a number n should be turned into the link
www.mysite.com/parts/n, then you can use a regex-based find-and-replace solution. You would want to look for the regex[A-Z]+:(\d+). What this says is “find one or more capital letters, a colon, and (capturing them) find one or more digits”. You then want to replace this with<a href='www.mysiste.com/parts/$1'>$0</a>; in this case,$1refers back to the capturing group (that is, the digits), and$0refers to the whole match. I don’t know C#, but I think this would look like