Well ... I did know before I looked at this that I was far from an expert in
regular expressions. But I know that even better now! But I think that I
did eventually find a solution.
I began by ignoring the replace aspect of the problem and tried to just find
a regular expression that would find the right ampersands. At first I did
not see how to find an "&" NOT followed by a specific STRING. But after
some research in the great Balena book I learned that I could use what is
called a "zero-width negative look-ahead assertion". The syntax for one of
those is "(?!subexpr)". So using this expression
(?<desiredamp>&(?!amp

)
I was able to find ampersands except for those followed by "amp;". Great!
I thought I was on my way and leapt, without sufficient thought, to
(?<desiredamp>&((?!amp

|(?!quote

))
but that catches all ampersands. It catches & because that's an & not
followed by "quote;". And catches "e; because that's an & not followed
by "amp;".
After more thought I came up with
(?<desiredamp>&(?!(amp

|(quote

))
which I think finds the ampersands which you want to find.
Another plug for Expresso, it was absolutely invaluable in researching this!
The expression above does find the & in "The & Lazy Dog". But if you don't
want that one I am sure you can see how to alter the expression to eliminate
it. I also did not worry about the replace aspect of the problem, I'm sure
you don't need help with that.
Good Luck, Bob
"barry" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> Thanks for your reply
>
> Imagine the following string
> string str = "The Quick Black&Fox & Jumped Over "e; The & Lazy
> Dog";
>
> should be
>
> string str = "The Quick Black&Fox & Jumped Over "e; The & Lazy
> Dog";
>
> This is a problem with a larger .xml file in which xx&xx is creating a
> problems in IE
>
> In fact in have just spent over 50 minutes and managed to get some results
> like this
>
> str = Regex.Replace(str, @"\b\s*(?=&[^&|"e;| & ])\b", "&",
> RegexOptions.None);
>
> And last but not the least i collect all answers posted to my Regex
> queries for later use.
>
>
>
>
>
>
>
>
> "eBob.com" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi Barry,
>>
>> Actually I wanted to play around with this for you but just haven't
>> gotten around to it. (And, btw, I don't recall any previous posts from
>> you on this subject.)
>>
>> Part of my response to you, the part I can provide without actually
>> playing with a regex, is the following. Regular Expressions are
>> extremely useful. If you do any programming the effort you put into
>> learning regular expressions will be worth it. Several of us here use
>> Expresso (from UltraPico) and recommend it. I just became aware of
>> something similar called Regular Expression Workbench available from
>> MSDN. I've installed it but have not yet played with it.
>>
>> I'll try to play with it later today but no promises.
>>
>> Bob
>>
>> "barry" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> strange, no one has replied
>>>
>>> looks like i have crossed the limit of asking question on the same
>>> topic. I the some limit maybe (10 or 15 per topic)
>>>
>>>
>>> "barry" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Hi
>>>>
>>>> I have a files which contains
>>>> &
>>>> &
>>>> "e;
>>>>
>>>> I want to replace & with & , but not & or "e;
>>>>
>>>> Will someone please help with the Regular Expression.
>>>>
>>>> TIA
>>>> Barry
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>