Re: Rexex replace

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




"Peter Duniho" <no.peted.spam@xxxxxxxxxxxxxxxxxx> wrote in message
news:ecMc6rCgKHA.5560@xxxxxxxxxxxxxxxxxxxxxxx
tshad wrote:
I am curious why my Regex would not work when like this

tableName = Regex.Replace(tableName, "'$", "")

But worked fine like this:

tableName = tableName.Replace("$", "");

Because the two are not the same? I don't know what you intend the "'$"
to do, but as far as I know it won't be anything useful in Regex. I don't
think it's the same as "find all instances of the '$' character".

As Jeff mentioned, there is an apostrophe there that I didn't see and it
should delete all "$", unless you need the "\" in front of it. Not sure
about that.

I think probably you want "\$" as your expression, but of course there
remains the question of why use Regex when the String.Replace() method
already does exactly what you want. The String method will be much more
efficient too.

It was there because it was actually part of a couple of other Regex
statements. I pulled it out to test it.

I did end up using the String.Replace but probably the Regex would also work
if it didn't have the apostrophe.

Thanks,

Tom


Pete


.



Relevant Pages

  • RE: XML Parsing error - regex problem?
    ... I've worked out that the character is a type of apostrophe which has a hex value of 92. ... How would I write my regex to substitute this character for a normal apostrophe? ... XML Parsing error - regex problem? ...
    (perl.beginners)
  • Re: Rexex replace
    ... tshad wrote: ... I don't think it's the same as "find all instances of the '$' character". ... I think probably you want "\$" as your expression, but of course there remains the question of why use Regex when the String.Replacemethod already does exactly what you want. ... The String method will be much more efficient too. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Keep only one part of a string
    ... Eero Saynatkari nous a dit: ... I'm pretty sure there is a String method that would keep only the first ... match of the regex but I didn't found it in the String doc reference ...
    (comp.lang.ruby)
  • Re: Keep only one part of a string
    ... Zouplaz wrote: ... I'm pretty sure there is a String method that would keep only the first ... match of the regex but I didn't found it in the String doc reference ...
    (comp.lang.ruby)
  • Keep only one part of a string
    ... I'm pretty sure there is a String method that would keep only the first match of the regex but I didn't found it in the String doc reference ...
    (comp.lang.ruby)