Text Manipulation

Discussion in 'ASP .Net' started by Mohamed Ahmed Meligy, Jun 17, 2004.

  1. 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, Jun 17, 2004
    #1
    1. Advertising

  2. Mohamed Ahmed Meligy

    Hans Kesting Guest

    "Mohamed Ahmed Meligy" <> wrote in message news:...
    > 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
    Hans Kesting, Jun 17, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jack-e

    text manipulation

    jack-e, Aug 9, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    346
    Oliver Wong
    Aug 9, 2005
  2. Tim Peters
    Replies:
    0
    Views:
    492
    Tim Peters
    Jan 24, 2004
  3. Johhny

    text manipulation

    Johhny, Dec 16, 2005, in forum: Python
    Replies:
    5
    Views:
    486
    BartlebyScrivener
    Dec 16, 2005
  4. ProvoWallis

    NewB question on text manipulation

    ProvoWallis, May 3, 2006, in forum: Python
    Replies:
    4
    Views:
    334
    ProvoWallis
    May 3, 2006
  5. Rex
    Replies:
    2
    Views:
    285
Loading...

Share This Page