Re: Regex Replace Help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello Barry,

Let's try to wriete out the pattern you're looking for.

You're specifically looking for a pattern that consists of an &, not followed by any alphanumeric characters and a ;. Now if you write it out like that, it becomes quite simple:

&(?![a-z0-9]+;)

That's it... Now, replace those with & and you're done.

Jesse


Thanks for your reply

Imagine the following string
string str = "The Quick Black&Fox & Jumped Over &quote; The & Lazy
Dog";
should be

string str = "The Quick Black&Fox & Jumped Over &quote; 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*(?=&[^&|&quote;| & ])\b", "&",
RegexOptions.None);

And last but not the least i collect all answers posted to my Regex
queries for later use.

"eBob.com" <fakename@xxxxxxxxxxxxxxxx> wrote in message
news:e20WY2sqIHA.4476@xxxxxxxxxxxxxxxxxxxxxxx

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" <someone@xxxxxxxxxxxxx> wrote in message
news:eIDvCEsqIHA.2520@xxxxxxxxxxxxxxxxxxxxxxx

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" <someone@xxxxxxxxxxxxx> wrote in message
news:Ot5OGUgqIHA.4912@xxxxxxxxxxxxxxxxxxxxxxx

Hi

I have a files which contains
&
&amp;
&quote;
I want to replace & with &amp; , but not &amp; or &quote;

Will someone please help with the Regular Expression.

TIA
Barry
--
Jesse Houwing
jesse.houwing at sogeti.nl


.



Relevant Pages

  • Re: Regex doubt
    ... regular expressions to match HTML. ... > I'm a bit of a newbie to RegEx - and I'm trying to write a RegEx which ... > pattern, match the pattern itself?In that case, the first pattern could be ...
    (microsoft.public.dotnet.framework)
  • [SUMMARY] Statistician I (#167)
    ... The heart of this problem, as suggested in the quiz description, is pattern ... have the pattern matching in place, the rest of the code is pretty trivial. ... use regular expressions, or at least review their knowledge. ... Next, as indicated in the comment, square brackets surrounding text are ...
    (comp.lang.ruby)
  • Re: position absolute different in IE than firefox, help!
    ... You referring to the F & R dialog box in BBEdit for Mac? ... Grep is the name of a frequently used Unix command that searches ... does is print out each line of the buffer that matches the pattern. ... The thing they have in common is regular expressions, ...
    (alt.html)
  • Re: Regex Replace Help
    ... Will this work on a entire XML file and there are ... And last but not the least i collect all answers posted to my Regex ... learning regular expressions will be worth it. ... I'll try to play with it later today but no promises. ...
    (microsoft.public.dotnet.framework)
  • Re: Verifying email address format
    ... >>If you were to use Regular Expressions, ... I knew full-well that the Regular Expression pattern I suggested was flawed, ... I think the rules are fairly strictly as to what characters are ... While it's true that email addresses are irregular, ...
    (microsoft.public.access.formscoding)