Saturday, March 24, 2012

Text Manipulation

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 ?"Mohamed Ahmed Meligy" <xmastereg@.hotmail.com> wrote in message news:evNi9RHVEHA.4028@.TK2MS
FTNGP09.phx.gbl...
> 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 o
f
> 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 "Microsof
t"
> 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 <),
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

0 comments:

Post a Comment