
regular expression question
I have had the same problem with the
C# documentation in .NET. It
clearly states "real~(ity)" matches "real" in "really" but not in
"reality"... and then you discover that the example doesn't work!
I built the regular expression "real(?!ity)", this matches the "real"
in "really" but does not match the "real" in "really".
I'm unsure as to where the documented example came from (and to be
honest I'm not sure how the above example works, as the syntax is
undescribed), but this works now.
Hope that's some help.
Chris Fox
Quote:
> Oh, yeah. More info about why I'm asking this question... I thought I had
> found a solution, here's what the docs say:
> Prevent match
> ~(X)
> Prevents a match when X appears at this point in the expression. For
> example, real~(ity) matches the "real" in "realty" and "really," but not the
> "real" in "reality."
> Only the example provided doesn't work at all, and neither do any of my own
> attempts to use ~().
> I hope someone can tell me why. Maybe I'm just being braindead today.
> TIA,
> Bob
> > I want to replace all occurances of "\cf1 " (where "1" could be any
> integer)
> > with " " where the expression is not immediately preceded by another "\".
> > Something akin to this:
> > mytext = New Regex("[^\\]\\cf[0-9]+ ").Replace(mytext, " ")
> > Only, I don't want to replace the beginning character [^\\].. I just want
> to
> > use it as a matching criteria. How do I do that? I'm hoping to be able to
> > accomplish this without loops.
> > Also, why doesn't replacing [0-9]+ in the matching pattern with [:z] work?
> > According to the docs, "cf[0-9]+" and "cf[:z]" should be equivalant but I
> > can't seem to get [:z] to work at all.
> > TIA,
> > Bob