[ddj] Dynamic backreferences?

Patrick Maynard patrickmaynard.bs at gmail.com
Wed Sep 25 20:15:45 UTC 2013


Is there a simple way to make a regular expression generate its own back
references?

For example, if I have strings "this is a <red,blue,green> set" and "this
is a <red,brown,blue,green,brown> string" (and several other strings that
vary in the number of color instances), and I know that the brackets will
always be exclusively wrapped around the comma-delimited color list, can I
write a single replacement pattern that will repeat each color three times
before going to the next color?

I realize that there are a ton of much better, non-big-hammer ways of doing
this. I'm just curious about this as a sort of academic exercise at this
point. Is there a way to accomplish this strictly with regex?

-- Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/data-driven-journalism/attachments/20130925/bac62ad6/attachment.html>


More information about the data-driven-journalism mailing list