help with regex

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am trying to include the literal '' (backslash) character in a regex.  
  I am not sure if I need to escape it, however...

 From :
"To include a backslash as a character without any special meaning  
inside a character class, you have to escape it with another backslash.  
[\x] matches a backslash or an x."

 From :
"...all  other  special  characters, including `', lose their special  
significance within a bracket expression."

These seem to contradict each other.  Both ways *seem* to work, but I am  
not familiar enough with regex's to know if one is producing some other  
side effect that I am not aware of.  Thanks a bunch for your help.

Re: help with regex

Quoted text here. Click to load it

I don't see the contradiction. What specifically do you find to be  
contradictory there? Backslash loses its special significance inside  
brackets, but you do need to escape it. Whenever you are referring to a  
literal backslash in a regex, put \ instead. Simple as that.

If you're still having problems, why not post your regex?

Photos from 40 countries on 5 continents:
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world:

Re: help with regex

Miguel Cruz wrote:

Quoted text here. Click to load it

My confusion came from the fact that I was interpreting this statement  
to mean that by losing its "special significance" (escape character), it  
was just treated as a literal character when inside [].

Re: help with regex

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Re: help with regex

John Dunlop wrote:
Quoted text here. Click to load it

I am new to PHP but I just saw a free tool for building pcre patterns.

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA    

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

Site Timeline