Loading ...
Sorry, an error occurred while loading the content.

use of \n in regex? [ was:regex to match paragraph]

Expand Messages
  • msws_1
    ... class. I made it: if ( param( acctinfo ) !~ /^[a-zA-Z0-9 &,# % * ( ) $ - + r n]{0,800} $/ ) { And yes, adding the r seems to have fixed it. I hadn t
    Message 1 of 5 , Apr 30, 2002
    • 0 Attachment
      > You've probably got \r's with your \n's. Add \r to the character
      class.

      I made it:

      if ( param('acctinfo') !~ /^[a-zA-Z0-9 &,#\%\*\(\)\$\-\+\r\n]{0,800}
      $/ ) {

      And yes, adding the \r seems to have fixed it. I hadn't tried the
      \r\n prior because of something I read. In light of these suggested
      fixes, I went and found it again:

      http://www.english.uga.edu/humcomp/perl/regex2a.html

      says:

      "
      Forbidden Characters

      Because of the way the searcher works, the following metacharacters
      should not be used, even though they are valid Perl metacharacters.

      They are:
      <snip>
      \n
      \r

      "

      So is it OK or not to use these metacharacters in my matching? Not
      sure what they mean by "searcher", but they seem pretty sure you
      shouldn't use the metacharacters.

      Thanks,
      Scott
    Your message has been successfully submitted and would be delivered to recipients shortly.