Thursday, May 5, 2011

A RegEx for: {0}

I feel like an idiot for asking this but what would a regular expression be to match the literal string: {0}

This would be used in JavaScript with the string object's replace function. I've tried several things and nothing seems to work.

Thanks,
Frank

From stackoverflow
  • "{0}".match(/\{0\}/)
    
  • Thank you bdonlan.

    Your post informed me that it wasn't my regEx but my use of the replace function.

    I was trying:

    MyString.replace(/\{0\}/, "test");
    

    And it should have been:

     MyString = MyString.replace(/\{0\}/, "test");
    

    Again, thank you!

0 comments:

Post a Comment