Results 1 to 3 of 3

Thread: Escaping $ in regular expression

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Ithaca, NY
    Posts
    145

    Escaping $ in regular expression

    I'm using preg_match() and I am trying to search a string for a bunch of characters but the $ is giving me a ton of grief...

    I have attempted the following forms of escaping it:

    PHP Code:
    '/\$/'

    '/\\$/'

    //and

    '/\\\$/'

    //I've also attempted this using double quotes with no luck... 
    So how do you escape a $ character within a regex in php?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Escaping $ in regular expression

    The first should work. What happens instead?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Ithaca, NY
    Posts
    145

    Re: Escaping $ in regular expression

    When I use \$ it always returns 1 no matter what.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width