tshabet has asked for the wisdom of the Perl Monks concerning the following question:
or<heading> level=2, Introduction to Arguments</heading>
In these snippets, I'd like to turn the<index> primary-key="listed-arguments", secondary-key="passing-functions", <paragraph> Arguments allow you to pass information to functions. There are two categories of arguments: </paragraph> </index>
into<foo> something=bar, Code is cool </foo>
that is, turn the something=bar into an attribute of the tag. So in order to do this, I implemented this regex:<foo something=bar> Code is cool </foo>
which, in my mind anyway, looks for the tag ending > followed by an optional space, then a "word"(plus numerals)/dashes followed by a mandatory equals sign followed by another word/dash/quotation mark combination followed by an optional comma. If the space or comma are found, they're eaten. The other stuff is replaced as an attribute.$text =~ s/>\s?([\w\-]*?)\=([\w\-\"]*?)\,?/ $1\=$2>/gixs;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Something's awry in my regex...
by MZSanford (Curate) on Aug 22, 2001 at 19:26 UTC | |
by petesmiley (Friar) on Aug 23, 2001 at 00:08 UTC |