| |||||||||||
| |||||||||||
patterns in patterns Posted by wilko (wilko), 29 January 2004 I am re-writing URLs in Perl to make them search engine friendly which is working well but I have a problem trying to figure the following:I am re-writing: index.cgi?n0=NAE&n1=12345678&NDBq=1> using: /index.cgi\?n0=NAE&n1=([0-9]*)&NDBq=([0-9]{1})>/ NAE$1NDBQ$2.html>/ to get: NAE12345678NDBQ1.html> (the > at the end is there to stop the pattern being greedy) My problem I want to replace $2 with $NDB[$2] where $2 is used to look up a value. The problem is that $NDB[X] has junk in it that needs to be removed using: /(.*)##(.......)##(.*)/$2/ I only want the bit between the ##s How can this pattern match be embedded into the first pattern making use of $2 from the first? Help please! Posted by admin (Graham Ellis), 29 January 2004 I think I would do it using several statements rather than just the one that would get over-complex. Something like:Code:
Posted by wilko (wilko), 29 January 2004 Sorry I omitted to say that I am replacing multiple occurrences of the pattern within the input variable. This is why I was trying to get a solution that does it all in one hit.$input =~ s/index.cgi\?n0=NAE&n1=([0-9]*)&NDBq=([0-9]{1})>/NAE$1NDBQ$2.html>/g; where $2 is the second pattern match It's got me foxed! BTW. This is a bit OT - I see you have a mixture of platforms in your office so wondered if you had any ideas how I can print from an OS9 Mac via ethernet to a non PostScript laser. Posted by admin (Graham Ellis), 30 January 2004 I still think I would do it in two steps - simply put the whole thing into while loop with a global flag; let me know if you would like me to post a sample or if this is sufficient guidance (I'm too jetlagged to write code tonight. Long flight, longer story of a failed aircraft ...)On the OS9 / Ethernet / Printer / non-postscript, we have examined the deep recesses of Lisa's memory ... the conclusion is that the viatl words are "non-postscript"; you would need a specific driver for the particular printer under OS9 - that's not the case for postscript, as there's a generic postscript driver in OS9. Posted by wilko (wilko), 2 February 2004 Thanks for that, I'll figure out the code.As for printing across a network to a non PS printer from a Mac, it seems that it's not that straightforward but I have found a product called Power Print for Networks. It's half software and half hardware. What I have at the moment is an old iMac sharing it's USB printer port which is working fine. When I stop resisting moving to OSX all these problems should go away! This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |