regex question "match everything that does not include the string '<br>'

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default regex question "match everything that does not include the string '<br>'

    Hi,

    I'm matching html using regex and use something like this to grab a
    chunk of text up to the next html tag:

    <font>([^<]+)</font>

    But I'd like to say "match everything that does not include the string
    <br>" rather than "match everything that does not include a "<"
    character. Anyone got any suggestions?

    Thanks,

    Mark

    Mark Maunder Guest

  2. Similar Questions and Discussions

    1. Can't find string terminator "EOM" - beginner question
      Hello, I am a beginner in Perl programming. Currently, I am using Perl 5.005_03 in my Solaris 8 server. I am getting the following error...
    2. Can a regex match numbers?
      Hello, please can you help me. Is it possible to specify number matching in a regex, i.e. can you have something like: my $match =~...
    3. RegEx to match names?
      There are a few different name formats out there, and I'm having trouble incorporating them into one regex. e.g. George Walker Bush George W....
    4. Regex to match ALL characters?
      Hi All, I'm trying to parse an Apache httpd.conf file to read the 'Alias' sections using PHP. Take the one below for example. I have worked out...
    5. Need regex to match "^\n"
      Hi: I am looking for a regex that will match a line with a single carrot: line = "^\n" However, the obvious does not seem to work:
  3. #2

    Default Re: regex question "match everything that does not include the string '<br>'

    On Jan 26, Mark Maunder said:
    >I'm matching html using regex and use something like this to grab a
    >chunk of text up to the next html tag:
    >
    ><font>([^<]+)</font>
    >
    >But I'd like to say "match everything that does not include the string
    ><br>" rather than "match everything that does not include a "<"
    >character. Anyone got any suggestions?
    First, I don't suggest using regexes to parse HTML.

    What you want, though, is:

    m{
    <font>
    ( (?: [^<]+ | < (?!/font>) )* )
    </font>
    }

    The middle part of that regex says "match either 'one or more non-<' or 'a
    < that is not followed by /font' zero or more times".

    --
    Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
    RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
    <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
    [ I'm looking for programming work. If you like my work, let me know. ]

    Jeff 'Japhy' Pinyan Guest

  4. #3

    Default Re: regex question "match everything that does not include the string '<br>'

    Thanks Jeff, that helps. I use HTML::Parser for various tasks, but for
    this particular one, I need exact matching, hence the regex.

    On Mon, 2004-01-26 at 09:57, Jeff 'japhy' Pinyan wrote:
    > On Jan 26, Mark Maunder said:
    >
    > >I'm matching html using regex and use something like this to grab a
    > >chunk of text up to the next html tag:
    > >
    > ><font>([^<]+)</font>
    > >
    > >But I'd like to say "match everything that does not include the string
    > ><br>" rather than "match everything that does not include a "<"
    > >character. Anyone got any suggestions?
    >
    > First, I don't suggest using regexes to parse HTML.
    >
    > What you want, though, is:
    >
    > m{
    > <font>
    > ( (?: [^<]+ | < (?!/font>) )* )
    > </font>
    > }
    >
    > The middle part of that regex says "match either 'one or more non-<' or 'a
    > < that is not followed by /font' zero or more times".
    >
    > --
    > Jeff "japhy" Pinyan [email]japhy@pobox.com[/email] [url]http://www.pobox.com/~japhy/[/url]
    > RPI Acacia brother #734 [url]http://www.perlmonks.org/[/url] [url]http://www.cpan.org/[/url]
    > <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
    > [ I'm looking for programming work. If you like my work, let me know. ]
    --
    Mark Maunder <mark@ziptree.com>
    ZipTree.com

    Mark Maunder Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139