2

I am working in replacing a text with a hyperlink in C#. The problem here is..

Case 1:No problem

Input: ASAss12345

Output:ASAss12345

Case 2:Problem here

Input: ASAss12345

Output:ASAss12345'>ASAss12345

Preferred Output: ASAss12345

How can I rectify this problem. Code her for your reference.

mailItem.HTMLBody = Regex.Replace(mailItem.HTMLBody, "(?<!http://stack.com/=)ASA[a-z][a-z][0-9][0-9][0-9][0-9][0-9](?!</a>)", "<a href='http://stack.com/=$&'>$&</a>");
John Saunders
  • 160,644
  • 26
  • 247
  • 397
c_prog_90
  • 951
  • 20
  • 43

1 Answers1

1

Take a look at this.

i think you are looking for This

Sangram Nandkhile
  • 17,634
  • 19
  • 82
  • 116
  • Converts string to hyperlink.thats what u have asked. – Sangram Nandkhile Jun 30 '11 at 14:39
  • How do I define LiteralName and site. They do exist in the current context. Also, where does Literalname.Text identify the regex pattern? – c_prog_90 Jun 30 '11 at 14:44
  • if u enter ASAss12345 then u need http://stack.com/r=ASAss12345..i didnt get that fr the 1st time.. its not complete answer but u should get ur answer from http://stackoverflow.com/questions/32637/easiest-way-to-convert-a-url-to-a-hyperlink-in-a-c-string did u check that? – Sangram Nandkhile Jun 30 '11 at 14:50
  • @ThinkKool: I had not checked before but i have just tested ur code on my own and found its running perfectly...I donno what mailItem.HTMLBody (something related with outlook ) is but if u try the same thing on Label.Text its work perfectly.. – Sangram Nandkhile Jun 30 '11 at 15:12