|
From: Ciszkowski, J. <Jac...@na...> - 2004-12-15 17:37:25
|
Does anyone happen to have a similar example in Java?
-----Original Message-----
From: Ciszkowski, Jacy=20
Sent: Wednesday, December 15, 2004 12:36 PM
To: Ciszkowski, Jacy; jed...@li...
Subject: RE: [ jEdit-users ] Search and Replace Question
A little PERL to get you on your way...
#!/usr/bin/perl -w
# Get your filename here
my $file=3D'inputfilename';
my $file2=3D$file.".bkp";
# open two files one to keep one to write to
open(INFILE, "<$file") || die "Couldn't open $file #!";
open(OUTFILE, ">$file2") || die "Couldn't open $file2 #!";
# Read in file
while(<INFILE>){
$line=3D$_;
# Test it in regex
if($_=3D~/regexhere/i){
# Format $line here and print it to your new file.
print OUTFILE "$line formatted here however you choose...";
}
=09
# Or uncomment to use substitution and print it that way...
#$line=3D~s///i;
} # End While
close(INFILE;
close(OUTFILE);
# P.S. There is always more cryptic but quicker ways to do things in =
PERL
# in fewer lines if you are bored...
# -Jacy-
-----Original Message-----
From: jed...@li...
[mailto:jed...@li...]On Behalf Of Ciszkowski,
Jacy
Sent: Wednesday, December 15, 2004 12:24 PM
To: jed...@li...
Subject: RE: [ jEdit-users ] Search and Replace Question
Andy,
PERL is definitly choice for what you are doing. I also am repeatedly =
replacing and formatting tons of text in log files and it only takes a =
couple lines of PERL code to get what you need quickly...
-Jacy-
-----Original Message-----
From: jed...@li...
[mailto:jed...@li...]On Behalf Of Randall R
Schulz
Sent: Wednesday, December 15, 2004 11:50 AM
To: jed...@li...
Subject: Re: [ jEdit-users ] Search and Replace Question
Andy,
On Wednesday 15 December 2004 08:26, Garst Andrew wrote:
> Hello All,
>
> Thanks so much Steve and others for your quick answer.
> Works like a charm.
> I'm not sure why I ever anchored it to the beginning of the line.
> Rooky mistake I'm sure.
>
> One more question.
> I regularly need to format large trace files (+/- 100,000 line).
> I have a set of Search and Replace Regular expressions strung
> together into a Macro in jEdit. When I run it, my machine freezes
> for 10 min or so.
> Now I'm not complaining as this is still WAY faster then me doing it,
> but would it be faster to download Active State (Or some other perl
> for Windows)
> and do the formatting all in Perl?
Always use the best tool available for the job. In this case, jEdit may=20
not be the best tool.
You say you're on Windows, but that does not cut you off from the Gnu=20
tools, since you still have access to the outstanding Cygwin=20
environment. In my Windows days, I could not possibly have done my=20
programming work without Cygwin.
<http://cygwin.com/>
Get it. Use it. You'll love it. It includes its own Perl as well as awk=20
(gawk), sed, grep / egrep, shells, cat, cut, paste, etc.
> Thanks for any insight,
> Andy
Randall Schulz
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.=20
http://productguide.itmanagersjournal.com/
--=20
-----------------------------------------------
jEdit Users' List
jEd...@li...
https://lists.sourceforge.net/lists/listinfo/jedit-users
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.=20
http://productguide.itmanagersjournal.com/
--=20
-----------------------------------------------
jEdit Users' List
jEd...@li...
https://lists.sourceforge.net/lists/listinfo/jedit-users
|