I would like to add html links in the following examples:
- Blah Blah Blah BZ#01234 Blah Blah Blah
- Blah Blah Blah BZ#0124 Blah Blah Blah
- Blah Blah Blah BZ 012345 Blah Blah Blah
- Blah Complex Blah BZ#123 , 345, 567,2341 Blah
So the look like:
- Blah Blah Blah <a href=”http://bz.com/show_bug.cgi?id=01234″>BZ#01234</a> Blah Blah Blah
- Blah Blah Blah <a href=”http://bz.com/show_bug.cgi?id=0124″>BZ#0124</a> Blah Blah Blah
- Blah Blah Blah <a href=”http://bz.com/show_bug.cgi?id=012345″>BZ 012345</a> Blah Blah Blah
- Blah Complex Blah <a href=”http://bz.com/show_bug.cgi?id=123″>BZ#123</a> , <a href=”http://bz.com/show_bug.cgi?id=345″>345</a>, <a href=”http://bz.com/show_bug.cgi?id=567″>567</a>,<a href=”http://bz.com/show_bug.cgi?id=2341″>2341</a> Blah
So I guess this is a regex job to find the matches, and some PowerShell magic to add the html links. I think the regex is ((BZ#)|(BZ ))[0-9]+ to match everything except the complex example, but I dont know regex well enough to be sure, or how to even test it in PowerShell.
I think this works, it depends on how variable the input can be.
Output: