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. Advertising

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

    On Wed, 29 Oct 2003 14:16:33 +0000, Steve Dunn wrote:
    [snip...]
    > p.s. I'm using the .NET regex classes


    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. Advertising

  3. Steve Dunn

    Ben Morrow Guest

    Brian Harnish <> wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----


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

    Ben

    --
    The cosmos, at best, is like a rubbish heap scattered at random.
    - Heraclitus
    Ben Morrow, Oct 29, 2003
    #3
    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. Prabh
    Replies:
    1
    Views:
    414
    Wendy S
    Sep 11, 2003
  2. Aubrey Hutchison

    GO AHEAD -MAKE ME LOOK DUMB- Please

    Aubrey Hutchison, Dec 31, 2003, in forum: Python
    Replies:
    4
    Views:
    307
    Aubrey Hutchison
    Dec 31, 2003
  3. inhahe
    Replies:
    3
    Views:
    2,322
    Diez B. Roggisch
    Jan 28, 2005
  4. Steve Dunn

    Repost: Conditional look-ahead?

    Steve Dunn, Oct 29, 2003, in forum: Perl Misc
    Replies:
    11
    Views:
    168
    Helgi Briem
    Oct 30, 2003
  5. Replies:
    4
    Views:
    160
Loading...

Share This Page