On Mar 17, 10:18 pm, "per" <pkl... gmail.com> wrote:
> Btw: I have some experience with Perl, but it is a
while back and I
> have forgotten most of it. It would be great if someone
could give me
> some brief instructions for how to use the script
Xicheng was generous
> enough to post.
>
> I have installed Active Perl on my Windows XP, and know
how to run the
> script. But that is about all.
>
> I believe I need to add a write/output part of the
script (the file
> should stay intact, only copying the "labels"
to the "CATEGORIES:"
> part of the file, once for each blog post segment of
the file), and is
> there anything else?
>
> Again, any suggestions are very much appreciated.
Hi, Per:
If you have installed Cygwin with Perl, then you can just
use the same
Linux command line to handle your file.. add an '-i' option
to modify
your file in-place, i.e.:
perl -i -0777pe '
s{^CATEGORIES:s*(.*?Labels:s*)
((?:<a[^>]*>(.*?)(?{$x .= "CATEGORIES:
$3n"})</a>(,s*)?)*)
}{$xn$1$2}msx
' mydoc.txt
If you use Active Perl under Windows console, then, use:
perl -0777pe
"s{^CATEGORIES:s*(.*?Labels:s*)((?:<a[^>]*>(
.*?)(?
{$x .= qq(CATEGORIES:
$3n)})</a>(,s*)?)*)}{$xn$1$2}msx" mydoc.txt
Note: under Windows, you may need to put all Perl commands
in one line
instead of using multiple lines as in Linux boxes..
Add an '-i' option to allow in-place modification, i.e.
perl -i.org -0777pr "....." mydoc.txt
This also generates a "mydoc.txt.org" in the same
directory which
saves the original file-contents of mydoc.txt..
Regards,
Xicheng
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|