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>");
6
  • @think: FYI, there's no such thing as "C Sharp". The language is named "C#". Commented Jun 30, 2011 at 13:59
  • Take a look at this...stackoverflow.com/questions/32637/… Commented Jun 30, 2011 at 14:08
  • ThinkKool: i had just checked ur code on my own and find it running perfectly... Commented Jun 30, 2011 at 15:09
  • Really! it is weird.. I tried this just now.. I does not work for me.. Commented Jun 30, 2011 at 16:11
  • Can u just skip the hyper linked text ?? i dont understand in case 2 , you are entering Hyperlinked text and in return u need the same hypelinked text again ?? one way can be to skip the Hyperlinked text and should only work for the text which is not hyperlinked.... Commented Jul 1, 2011 at 6:10

1 Answer 1

1

Take a look at this.

i think you are looking for This

Sign up to request clarification or add additional context in comments.

4 Comments

Converts string to hyperlink.thats what u have asked.
How do I define LiteralName and site. They do exist in the current context. Also, where does Literalname.Text identify the regex pattern?
if u enter ASAss12345 then u need stack.com/r=ASAss12345..i didnt get that fr the 1st time.. its not complete answer but u should get ur answer from stackoverflow.com/questions/32637/… did u check that?
@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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.