regular expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven D'Aprano

    #16
    Re: regular expression

    On Mon, 25 Dec 2006 06:17:00 -0800, deviantbunnylor d@gmail.com wrote:
    Hi folks, fairly new to the list(Python is my first programming
    language, so I'm fairly new to the world of programming too)but this is
    a question I've been wondering about since I started learning about the
    re module. Are regular expressions what makes mark up languages
    interpretable by webbrowsers?
    Web browsers have to render HTML, which implies they must be able
    to parse and interpret at least one markup language. _How_ they parse the
    markup is up to the browser developers.

    Since regular expressions are very good at certain types of text parsing,
    and are widely available, it is probable that regular expressions are used
    in some (many? all?) markup parsers, simply because it is widely available
    and is a good tool for some (but not all) parsing tasks. For example,
    Python's xmllib module uses reg exps to parse xml.

    Essentially, a regular expression engine is a super-charged "find"
    command on steroids. But that doesn't mean that reg exps are the only tool
    for the job. A markup parser doesn't necessarily need to use regexes.


    --
    Steven.

    Comment

    • Tim Streater

      #17
      Re: regular expression

      In article <4587dc54$0$184 60$e4fe514c@dre ader31.news.xs4 all.nl>,
      Kleine Aap <een-niet-bestaande-kleineaap@xs4al l.nlwrote:
      Asper Faner wrote:
      >
      I seem to always have hard time understaing how this regular expression
      works, especially how on earth do people bring it up as part of
      computer programming language. Natural language processing seems not
      enough to explain by the way. Why no eliminate it ?
      >
      I.M.H.O. anyone that is not capable to grasp the concept of regular
      expressions should not attempt to write computer programs at all! My
      suggestion to you would be to find a job that involves working with your
      hands...
      This is complete rubbish. Regular expressions may be very clever but
      lead to unreadable code. They no doubt can be useful but the fact that a
      never-ending stream of people seek help with them in this and other
      groups indicates how bad they are. As does the fact that many people
      also ask about programs to generate them.

      I grasp the *concept* with no trouble at all. I have no intention of
      ever using them, however, as I like to be able to maintain the code I
      write.

      -- tim

      Comment

      • Michael Fesser

        #18
        Re: regular expression

        ..oO(Tim Streater)
        >In article <4587dc54$0$184 60$e4fe514c@dre ader31.news.xs4 all.nl>,
        >
        >This is complete rubbish.
        No.
        >Regular expressions may be very clever but
        >lead to unreadable code.
        Unreadable would be the code that you would have to use for some
        particular problems if you would not use regexps. It's the power of them
        that lets you solve many problems with a single line of code.
        >They no doubt can be useful but the fact that a
        >never-ending stream of people seek help with them in this and other
        >groups indicates how bad they are.
        They are not bad, just a bit difficult to understand at first.
        >As does the fact that many people
        >also ask about programs to generate them.
        Just because some people don't understand a technique doesn't mean that
        the technique itself is bad. If you want to use a particular tool then
        you have to learn how to use it. You can't blame the tool for your lack
        of knowledge.
        >I grasp the *concept* with no trouble at all. I have no intention of
        >ever using them, however, as I like to be able to maintain the code I
        >write.
        Me too. That's why I use regexps, when it comes to pattern matching.

        Micha

        Comment

        • R. Rajesh Jeba Anbiah

          #19
          Regex tools (Was Re: regular expression)

          [reply set only to comp.lang.php]

          Rad [Visual C# MVP] wrote:
          <snip>
          A good tool to write, test and analyse regexes is the Regulator, available
          here http://sourceforge.net/projects/regulator/
          It looks like that The Regex Coach still rules
          <http://weitz.de/regex-coach/>

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          • Rik

            #20
            Re: regular expression

            Michael Fesser wrote:
            .oO(Tim Streater)
            >
            >In article <4587dc54$0$184 60$e4fe514c@dre ader31.news.xs4 all.nl>,
            >>
            >This is complete rubbish.
            >
            No.
            >
            >Regular expressions may be very clever but
            >lead to unreadable code.
            >
            Unreadable would be the code that you would have to use for some
            particular problems if you would not use regexps. It's the power of
            them that lets you solve many problems with a single line of code.
            And just use the /x modifier, and comment your regex as you would normal
            code. Highly recommended for future readablity.

            --
            Rik Wasmus


            Comment

            • Curtis

              #21
              Re: regular expression

              Rik Wasmus wrote:
              And just use the /x modifier, and comment your regex as you would normal
              code. Highly recommended for future readablity.
              I noticed that very few people do this, and, I have to admit, I don't
              do it that often either.

              Tim Streater wrote:
              I grasp the *concept* with no trouble at all.
              Do you really? If they're so easy to you, then I don't see how you're
              getting readability problems, unless you're mishandling them. As noted
              above, the /x modifier is very helpful in crafting complex regexes.

              Comment

              Working...