#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    59
    Rep Power
    7

    Signaficance of the sign #


    Hello Mates,
    A very basic question. How does the sign '#' effects any RE. For example the following RE
    Code:
    #(alert|cmd|passthru|eval|exec|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si
    . What's the signaficance of the sign '#'. If anyone can kindly help me with this, that woudl be very much appreciated. Thank you.
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    937
    Assuming it is a Perl, PHP or some similar regex flavour, it probably is just a delimiter.
    Most of the times, the forward slash is used, but you can use other delimiters, like the hash character (#).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    59
    Rep Power
    7
    Originally Posted by prometheuzz
    Assuming it is a Perl, PHP or some similar regex flavour, it probably is just a delimiter.
    Most of the times, the forward slash is used, but you can use other delimiters, like the hash character (#).
    Thank you, mate. I was using RE in PHP. Thankx.
  6. #4
  7. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    497
    Rep Power
    937
    Originally Posted by taneem
    Thank you, mate. I was using RE in PHP. Thankx.
    No problem.
    Most of the time you see people using the forward slash:

    PHP Code:
    '/some-regex-here/' 
    But when you want to match a forward slash in your regex, you would need to escape it, otherwise the regex engine "thinks" your regex terminates too early:

    PHP Code:
    '/some-regex\/here/' 
    in which case many people use another delimiter so that they need not escape the slash:

    PHP Code:
    '#some-regex/here#' 
    HTH
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    59
    Rep Power
    7
    Originally Posted by prometheuzz
    No problem.
    Most of the time you see people using the forward slash:

    PHP Code:
    '/some-regex-here/' 
    But when you want to match a forward slash in your regex, you would need to escape it, otherwise the regex engine "thinks" your regex terminates too early:

    PHP Code:
    '/some-regex\/here/' 
    in which case many people use another delimiter so that they need not escape the slash:

    PHP Code:
    '#some-regex/here#' 
    HTH
    Got it. RE is quite a handly tool to stop hackers in terms of form input. That's why I need to learn them good. Thankx.

    Comments on this post

    • requinix agrees : uh oh...

IMN logo majestic logo threadwatch logo seochat tools logo