Find and replace problem

Discussion in 'ASP .Net' started by =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Aug 15, 2005.

  1. I have the following text:-

    Brian went to stadium to watch the soccer game, Brian MacWoods is bussiness
    man and very rich man.
    Brian likes to run every morning on beachside.

    the problem i have I get the list of words that should be replace in the
    provided text as follows:-

    Brian (ONLY) : should be replaced by Mr with Brian word itself==> will be
    after replacing(Mr Brian)
    Brian MacWoods (Togather): should be replace by Sr with Brian MacWoods = >
    will be after replacing(Sr Brian MacWoods)

    how can i achieve this stuff of text replacing without have problem in the
    name conflict (that when replay Brian(ONLY) do not replace the Brian in Brian
    MacWoods?
     
    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Aug 15, 2005
    #1
    1. Advertising

  2. This is a work around

    First replace Brian with Mr Brian
    MyString.Replace("Brian", "Mr Brian");

    Then replace Mr Brian MacWoods (notice the "Mr" is now included) with Sir
    Brian McWoods
    MyString.Replace("Mr Brian MacWoods", "Sir Brian MacWoods");

    HTH

    "Raed Sawalha" <> wrote in message
    news:...
    >
    > I have the following text:-
    >
    > Brian went to stadium to watch the soccer game, Brian MacWoods is
    > bussiness
    > man and very rich man.
    > Brian likes to run every morning on beachside.
    >
    > the problem i have I get the list of words that should be replace in the
    > provided text as follows:-
    >
    > Brian (ONLY) : should be replaced by Mr with Brian word itself==> will be
    > after replacing(Mr Brian)
    > Brian MacWoods (Togather): should be replace by Sr with Brian MacWoods = >
    > will be after replacing(Sr Brian MacWoods)
    >
    > how can i achieve this stuff of text replacing without have problem in the
    > name conflict (that when replay Brian(ONLY) do not replace the Brian in
    > Brian
    > MacWoods?
    >
    >
    >
     
    Grant Merwitz, Aug 15, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Ankit Gurjar Guest

    Hello Raed,

    Here you have to make two searches for separate words Brian and
    Brian MacWoods. First Search for Word Brian, if you find the match then
    search for Brian MacWoods using SubString(strString, intstartPosition,
    intStartPosition + Len("Brian MacWoods").

    Now of you find the second match then replace for Brian MacWoods
    else Replace for Brian only. So here you are searching for Brian first and
    immediately searching for Macwoods in next 9 Characters.

    I hope this will sort out your problem.


    --
    Ankit Gurjar


    "Raed Sawalha" <> wrote in message
    news:...
    >
    > I have the following text:-
    >
    > Brian went to stadium to watch the soccer game, Brian MacWoods is
    > bussiness
    > man and very rich man.
    > Brian likes to run every morning on beachside.
    >
    > the problem i have I get the list of words that should be replace in the
    > provided text as follows:-
    >
    > Brian (ONLY) : should be replaced by Mr with Brian word itself==> will be
    > after replacing(Mr Brian)
    > Brian MacWoods (Togather): should be replace by Sr with Brian MacWoods = >
    > will be after replacing(Sr Brian MacWoods)
    >
    > how can i achieve this stuff of text replacing without have problem in the
    > name conflict (that when replay Brian(ONLY) do not replace the Brian in
    > Brian
    > MacWoods?
    >
    >
    >
     
    Ankit Gurjar, Aug 15, 2005
    #3
    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. Brian Blais
    Replies:
    1
    Views:
    382
    Bruno Desthuilliers
    Jun 27, 2006
  2. Greg Ewing
    Replies:
    2
    Views:
    345
    Dieter Maurer
    Jun 29, 2006
  3. Wybo Dekker
    Replies:
    1
    Views:
    362
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    411
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    813
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page