Conditional look-ahead?

Discussion in 'Perl Misc' started by Steve Dunn, Oct 29, 2003.

  1. Steve Dunn

    Steve Dunn Guest

    I'm stuck with a regular expression that closes tags if a closing tag
    doesn't already exist. It's probably easier to demonstrate than explain, so
    here goes:

    I need to turn the following structure:

    <TAG1>
    <TAG2>foo
    <FOOBAR>
    <TAG3>I'm ok</TAG3>
    </TAG1>

    into the follow:

    <TAG1>
    <TAG2>foo</TAG2>
    <TAG3 />
    </TAG1>

    So, TAG1 and TAG3 are left alone, as they contains a closing tag, TAG2 is
    closed because there's text and no closing tag, and <FOOBAR> is closed
    because there's no text and closing tag.

    Any help very much appreciated,

    Thanks,

    Steve.
    p.s. I'm using the .NET regex classes
     
    Steve Dunn, Oct 29, 2003
    #1
    1. Advertisements

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    ]
    So, then, your asking in a perl group why?

    Try a .NET group.

    - Brian
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.2 (GNU/Linux)

    iD8DBQE/n+OKiK/rA3tCpFYRAiv7AJ9t6RpNYJsVucIZYfHNznev7sJzPACfW3oA
    FrXF4X7/pRB2ddi0kClTigQ=
    =Zdft
    -----END PGP SIGNATURE-----
     
    Brian Harnish, Oct 29, 2003
    #2
    1. Advertisements

  3. Steve Dunn

    Ben Morrow Guest

    Not wishing to cause trouble or anything, but is it *really* necessary
    to sign a message which is itself shorter than the signature?

    Ben
     
    Ben Morrow, Oct 29, 2003
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.