Regular Expression help - Does (.) Mean new line?

  • Weegee2017

    SSC Eights!

    Points: 962

    Hi there


    I am re-writing some code which uses regular expressions

    Part of the code uses the following:

    ^(.){1,50}$'', 0)'

    Does this mean …. any character where the string is between 1 and 50 characters

    but the (.) means cannot contain newline?

    And does it mean no newline character at the beginning?





  • Mr. Brian Gale


    Points: 22548

    Have a look at this webpage:

    It lets you test out RegEx and it provides an explanation of what the regex is doing.

    Your understanding of that part is correct.  (.) is any character except new line, ^ is starts with and {1,50} means it can be between 1 and 50 characters long.  The $ means "asserts position at the end of the string, or before the line terminator right at the end of the string (if any)" so I am not entirely sure what your regex is doing with the '',0)' at the end, but I expect it not to find any matches ever as $ basically means "ends with" and applies to the characters before it.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply