regex

Discussion in 'Perl Misc' started by boris bass, Aug 25, 2003.

  1. boris bass

    boris bass Guest

    the following is the text string i am trying to match


    bgColor=#ffffff

    and i constructed the following regular expr


    while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )


    and it doesnt seem to be working


    I am actually trying to match from the equal sign and rightward, i.e.
    match equal sign followed by zero or more whitespaces followed by the
    pound sign followed by exactly six alphanumerics and NOT QUOTED -

    NOT QUOTED is the whole point of a match

    any suggestions appriciated
    boris bass, Aug 25, 2003
    #1
    1. Advertising

  2. boris bass <> wrote:

    > the following is the text string i am trying to match
    >
    > bgColor=#ffffff



    > I am actually trying to match from the equal sign and rightward, i.e.
    > match equal sign followed by zero or more whitespaces followed by the
    > pound sign followed by exactly six alphanumerics and NOT QUOTED -
    >
    > NOT QUOTED is the whole point of a match



    /=\s*#\w{6}/
    or
    /=\s*#\w{6}(?!")/


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Aug 25, 2003
    #2
    1. Advertising

  3. boris bass wrote:
    >
    > the following is the text string i am trying to match
    >
    > bgColor=#ffffff
    >
    > and i constructed the following regular expr
    >
    > while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )
    >
    > and it doesnt seem to be working
    >
    > I am actually trying to match from the equal sign and rightward, i.e.
    > match equal sign followed by zero or more whitespaces followed by the
    > pound sign followed by exactly six alphanumerics and NOT QUOTED -
    >
    > NOT QUOTED is the whole point of a match
    >
    > any suggestions appriciated



    $ perl -le'
    for ( q/bgColor=#ffffff/, q/bgColor="#ffffff"/, q/ bgColor = #ffffff /, q/ bgColor = "#ffffff" / ) {
    print if /=\s*(?<!")#[[:xdigit:]]{6}(?!")/;
    }
    '
    bgColor=#ffffff
    bgColor = #ffffff



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn, Aug 25, 2003
    #3
  4. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    (boris bass) wrote in news:65fcb898.0308250725.18cf440
    @posting.google.com:

    > the following is the text string i am trying to match
    >
    >
    > bgColor=#ffffff
    >
    > and i constructed the following regular expr
    >
    >
    > while ( $content =~ /=\s*[^"]#\w{6}[^"]/ )


    The problem is that

    [^"]

    matches "exactly one character that is not a quote". So it requires one
    non-quote character between the optional whitespace and the # symbol.

    You really don't need the [^"] business. If you are matching on \w{6},
    it'll match six word characters; any quotes would cause the match to fail
    anyhow.

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP0q5xmPeouIeTNHoEQKxWgCg49tuMBDtc2jBGlGlAq6k4EgPlFkAn1Gk
    iXyn5MLSm3qvcw0y/ShqKMsy
    =fIVV
    -----END PGP SIGNATURE-----
    Eric J. Roode, Aug 26, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    690
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,608
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    589
  4. Xah Lee
    Replies:
    1
    Views:
    931
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    734
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page