Text Manipulation

  • Thread starter Mohamed Ahmed Meligy
  • Start date
M

Mohamed Ahmed Meligy

Can't anyone help me with this ?
I need it very soon to finish my project before sataerday.
Thank you in advance.
I want to develop a content management component that suits a blog or a
portal.
In it I develop an article authoring/browsing tool withwhich I do have a
problem.
When posting an Article, I want to replace each word like microsoft with
<a href=http://www.microsoft.com">Microsoft</a> where
http://www.microsoft.com is stored in the database. This is not a very big
problem I think especially using "foreach" in C#.
My real problem is tat I may provide the same word "Microsoft" as a part of
a URL liike
<a
href=http://www.microsoft.com/technet/community/scriptcenter/default.mspx">
Check out the new scripts in the TechNet Script Center </a>
or even an <asp:Hyperlink> ... In such cases, replacing the word "Microsoft"
is never wanted as it'll make a big problem to me.
How should I do that ?
 
H

Hans Kesting

Mohamed Ahmed Meligy said:
Can't anyone help me with this ?
I need it very soon to finish my project before sataerday.
Thank you in advance.
I want to develop a content management component that suits a blog or a
portal.
In it I develop an article authoring/browsing tool withwhich I do have a
problem.
When posting an Article, I want to replace each word like microsoft with
<a href=http://www.microsoft.com">Microsoft</a> where
http://www.microsoft.com is stored in the database. This is not a very big
problem I think especially using "foreach" in C#.
My real problem is tat I may provide the same word "Microsoft" as a part of
a URL liike
<a
href=http://www.microsoft.com/technet/community/scriptcenter/default.mspx">
Check out the new scripts in the TechNet Script Center </a>
or even an <asp:Hyperlink> ... In such cases, replacing the word "Microsoft"
is never wanted as it'll make a big problem to me.
How should I do that ?

Assuming that the text is html, so that a literal "<" is encoded (as &lt;),
you can walk through the string, noting start (<) and finish (>) of tags.
Replace only in texts that are not tags.
The rest is left as an exercise for the reader :)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top