eHam.net - Amateur Radio (Ham Radio) Community

Call Search
     

New to Ham Radio?
My Profile

Community
Articles
Forums
News
Reviews
Friends Remembered
Speak Out
Strays
Survey Question

Operating
Contesting
DX Cluster Spots
Propagation

Resources
Calendar
Classifieds
Ham Exams
Ham Links
List Archives
News Articles
Product Reviews
QSL Managers

Site Info
eHam Help (FAQ)
Support the site
The eHam Team
Advertising Info
Vision Statement
About eHam.net


QSL Managers
     

Ham Links
     


eHam.net Forum : CW : Utility to strrip odd punctuation from text? Forum Help

1-10 of 24 messages

  Page 1 of 3   Next


Utility to strrip odd punctuation from text? Reply
by K6DZ on June 20, 2007 Mail this to a friend!
Gang, A few years ago I found a DOS utility that would search any computer text file for $ % ( ! etc. and remove such characters, and long spaces too, leaving the file with only letters, numbers, ,?/.

Now I lost it, anybody know where one for Windows can be found nowadays?

TNX
 
RE: Utility to strrip odd punctuation from text? Reply
by KB1OOO on June 21, 2007 Mail this to a friend!
The best way would be vis a utility that does regular expressions. E.g. sed, which is standard on unix machines. On windows it's available if you have cygwin installed. You can also install a win32 version of it: Dowload the following 2 zips.

http://gnuwin32.sourceforge.net/downlinks/sed-bin-zip.php
http://gnuwin32.sourceforge.net/downlinks/sed-dep-zip.php

Copy the contents of the bin directories from them to your c:windowssystem32 directory. Now put the following line in a text file (say stripOddCharsCommand.txt) all by itself:

s/[~@#$%^&*()]//g

Now run the command

sed -f stripOddCharsCommand.txt fileToStrip.txt > outputStrippedFile.txt

where fileToStrip.txt is the text file that you want to strip and outputStrippedFile.txt is the output file.

You can modify what characters that get stripped in the command above. E.g. if you don't want to get rid of the @ symbol then remove the @. If you want to add a character that's not there, then inserted it somewhere in between the square brackets. It must be escaped with the backslash.

Hope this helps.

Marc
 
RE: Utility to strrip odd punctuation from text? Reply
by KB1OOO on June 21, 2007 Mail this to a friend!
sorry, missed the long space requirement. Add the following line to stripOddCharsCommand.txt from my previous email:

s/ {4,}/ /g

so that the file now contains

s/[~?@#$%^&*()]//g
s/ {4,}/ /g

This will replace strings of 4 spaces or more with one space. Change the number 4 as desired.
 
RE: Utility to strrip odd punctuation from text? Reply
by WQ3T on June 21, 2007 Mail this to a friend!
This isn't the most elegant way to do it in PERL,
but it does work:

#!C:\perl\bin\perl
#$Id$

use strict;
use warnings;
my $filename = shift;
my @buff;

if (-e $filename) {
open(INFILE, $filename);
while(<INFILE>) {
my ($a) = $_;
chomp($a);
$a =~ s/[^a-zA-Z0-9]//g;
push(@buff, $a);
}
close(INFILE);
open(OUTFILE, ">$filename");
foreach (@buff) {
print (OUTFILE "$_n");
}
close(OUTFILE);
}
else {
print "NO FILEn";
}
 
RE: Utility to strrip odd punctuation from text? Reply
by KE3WD on June 21, 2007 Mail this to a friend!
Since I can't vouch for any of them, will just tell you that I did a websearch for "freeware shareware text find and remove multiple entries" and it returns a lot of possibilities for windows OS out there.

If you don't want to pay money, elminate the "shareware" from the searh and see what comes up.

One or more of them should work for what you wish to do.


Luck,


.
 
RE: Utility to strrip odd punctuation from text? Reply
by KC9HOZ on June 21, 2007 Mail this to a friend!
Would the "find and replace" function in most text editors do this too? (never tried it personally)

Scott kc9hoz
 
RE: Utility to strrip odd punctuation from text? Reply
by KE3WD on June 21, 2007 Mail this to a friend!
"Find and Replace" as found in many word processors would conceivably work, sort of, I thought of that first, but there is a problem in that you have to replace the character with something. Even a space, but depending on the intended use for the text in question, may prove problematic. For a CW reader, it might just make extra space time, which could make for a hard read while attempting to copy for some.

Of course, you might replace the # sound with NR or even the word "numbersign"...


.
 
RE: Utility to strrip odd punctuation from text? Reply
by KB1OOO on June 21, 2007 Mail this to a friend!
> Would the "find and replace" function in most text editors do this too?
> (never tried it personally)

Yes, any editor that supports regular expressions. Traditional examples are vim and emacs, but a more user friendly one for windows is textpad.
 
RE: Utility to strrip odd punctuation from text? Reply
by KB1OOO on June 21, 2007 Mail this to a friend!
in the perl example, the regular expression doesn't retain the valid punctutation. You should add ,?./ so that it becomes

$a =~ s/[^a-zA-Z0-9,?./]//g;

This regex will work in my sed script as well.

Also, the perl script won't handle the long spaces. For that add the following line which is the same regex but in perl you don't escape the curly braces
$a =~ s/ {4,}/ /g;

Again change the number 4 as desired.

Marc
 
RE: Utility to strrip odd punctuation from text? Reply
by K6DZ on June 21, 2007 Mail this to a friend!

Thanks, all.

Unfortuneately my desktop is on the fritz and am forced to a crappy old laptop where I don't have room to install redhats' cygwin !

http://www.freebestsoft.com/15735/Remove-Delete-Text-Spaces-&-Characters-From-Tex-download.html

is twenty buck shareware but the free trial won't display what it actually does.

I'm stuck with a slow process, namely letting code learning software (Just Leaern Morse Code) do the conversion @ 100 W.P.M. and then cut and paste the new file version from the JLMC morse code output display frame e.g.


JLMC Input frame:


1962 Batting Average Leaders
~!@#$%^&*()_+^%$#&((__))
Top 7 in the National League
Name Batting Average Team Rank
Tommy Davis, .346 (.34586)? Los Angeles Dodgers 1
Frank Robinson, .342 (.34154)? Cincinnati Reds 2
Stan Musial, .330 (.33025)? St. Louis Cardinals 3
Bill White, .324 (.32410)? St. Louis Cardinals 4
Hank Aaron, .323 (.32264)? Milwaukee Braves 5
George Altman, .318 (.31835)? Chicago Cubs 6
Felipe Alou, .316 (.31551)? San Francisco Giants 7


JLMC output frame:

1962 BATTING AVERAGE LEADERS TOP 7 IN THE NATIONAL LEAGUE NAME BATTING AVERAGE TEAM RANK TOMMY DAVIS, .346 .34586? LOS ANGELES DODGERS 1 FRANK ROBINSON, .342 .34154? CINCINNATI REDS 2 STAN MUSIAL, .330 .33025? ST. LOUIS CARDINALS 3 BILL WHITE, .324 .32410? ST. LOUIS CARDINALS 4 HANK AARON, .323 .32264? MILWAUKEE BRAVES 5 GEORGE ALTMAN, .318 .31835? CHICAGO CUBS 6 FELIPE ALOU, .316 .31551? SAN FRANCISCO GIANTS 7

Thanks again!
 

  Page 1 of 3   Next

 
Next Topic:   Testing
Previous Topic:   How to make the # sign?
Email Subscription
You are not subscribed to this topic.

Subscribe!
My Subscriptions
Subscriptions Help


Search CW:

Check our help page for help using Forum, or send questions, comments, or suggestions to the Forum Manager.