Spaces and newlines in regular expressions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kyle

    Spaces and newlines in regular expressions

    How can I signify a space or a newline in a regular expression? Are
    they just represented by whitespace and \n?

    Thanks!
  • Ian.H

    #2
    Re: Spaces and newlines in regular expressions

    On Fri, 20 Aug 2004 10:55:20 -0700, Kyle wrote:
    [color=blue]
    > How can I signify a space or a newline in a regular expression? Are
    > they just represented by whitespace and \n?
    >
    > Thanks![/color]


    Yup. Although you can also use \s for a space too, useful when looking for
    the likes of '\s*' or '\s{1,8}' etc etc.

    Something that might help you.. although I've posted it here before:


    <http://weitz.de/regex-coach/>




    Regards,

    Ian

    --
    Ian.H
    digiServ Network
    London, UK


    Comment

    • Elliott C. Bäck

      #3
      Re: Spaces and newlines in regular expressions

      Kyle wrote:
      [color=blue]
      > How can I signify a space or a newline in a regular expression? Are
      > they just represented by whitespace and \n?
      >
      > Thanks![/color]

      There's a character class "\s" that matches any whitespace character.
      You can also use the regex form "/regex/s" to turn on PCRE_DOTALL, so
      that the dot will match the "\n" newline characters as well. Note that
      newlines are platform dependant and can be "\n" or "\r\n," etc...
      --
      Elliott C. Bäck
      Sitemizi sizleri en iyi iddaa bahis siteleriyle buluşturmak için açmış bulunmaktayız arkadaşlar. Burada Türkiye'nin seçilmiş kaliteli ve güvenilir bahis sitelerini bulabilirsiniz. Kayıt, üyelik, para yatırma, para çekme, canlı bahis, giriş veya mobil giriş gibi birçok konuya değinerek en ince ayrıntısına kadar sitelerin detaylarını sizlere sunmaktayız. Ayrıca bahis hakkında çok çeşitli bilgiler de bulma şansınız var.

      Comment

      • Kyle James Matthews

        #4
        Re: Spaces and newlines in regular expressions

        Ian.H wrote:
        [color=blue]
        > Something that might help you.. although I've posted it here before:
        >
        >
        > <http://weitz.de/regex-coach/>
        >[/color]

        Wow, this is great! Thank you!

        Kyle

        Comment

        Working...