Conditional look-ahead?

S

Steve Dunn

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
 
B

Brian Harnish

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

]
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-----
 
B

Ben Morrow

Brian Harnish said:
-----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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top