ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

macro to edit a .txt file?

<< < (2/4) > >>

Ath:
Well, I didn't say sed was easy ;D

You'd get the desired result by using this command-line:

--- Code: Text ---sed -r -e 's/[0-9"]//g' input-file >output-fileOr optionally add the -i parameter and remove the '>output-file' part to do a destructive, in-place, replacement in multiple input-files but not keeping the original file(s).

bit:
Well, I didn't say sed was easy ;D

You'd get the desired result by using this command-line:

--- Code: Text ---sed -r -e 's/[0-9"]//g' input-file >output-fileOr optionally add the -i parameter and remove the '>output-file' part to do a destructive, in-place, replacement in multiple input-files but not keeping the original file(s).
-Ath (September 29, 2015, 10:17 AM)
--- End quote ---
I clicked on 'Select', and copy & paste highlighted string into top window of SedTester, then pasted sample text in which each line is consecutively numbered into first large window.
Second large window says:
sed: -e expression #1, char 26: Unterminated 's' command
Error 1

I tried individually checking each check box, but no success yet.
Tnx. Over to you?

Ath:
I was referring to a Linux or DOS (with sed added) command-line, not to SedTester.

In SedTester you'd have to only paste the quoted part in the SED expression field: s/[0-9"]//g
and check the -r checkbox
Like this (I pasted the Input text from AbteriX' post):

macro to edit a .txt file?

bit:
I was referring to a Linux or DOS (with sed added) command-line, not to SedTester.

In SedTester you'd have to only paste the quoted part in the SED expression field: s/[0-9"]//g
and check the -r checkbox
Like this (I pasted the Input text from AbteriX' post):

[ Invalid Attachment ]
-Ath (September 30, 2015, 01:24 AM)
--- End quote ---
Success! Wow, that's powerful!
PS - I see you also check-boxed 'Autocheck'; and when I did that, it worked.  :Thmbsup:
PS - For some text, the unwanted numbers look like this:
1:1: (plus desired text)
1:2:
1:3:

With s/[0-9"]//g only, it leaves this:
 : : (plus desired text)
 : :
 : :

If I add : to the script, like this: s/[0-9":]//g
it also removes all the colons [:]

Some text sources list unwanted numbers in [square brackets], and although SedTester still removes the numbers, the square brackets cannot be removed with SedTester.
However, a simple text 'search & replace' for the brackets or colons easily removes them all.

PS - Is there a way to increase the text body size limit to, say, 50 pages of text?
I froze up SedTester with a 13 page text file size.

4wd:
Some text sources list unwanted numbers in [square brackets], and although SedTester still removes the numbers, the square brackets cannot be removed with SedTester.-bit (September 30, 2015, 01:50 AM)
--- End quote ---

s/[][0-9\":]//g

Place the closing square bracket immediately after the opening square bracket, it'll be read as a character, and so will the following opening square bracket.

You also need to escape the quote (\") to have them removed.

macro to edit a .txt file?

You could also remove double spaces created by character removal (see last two lines in example) by using a SED Script:

s/[][0-9\":]//g
s/(  )/ /g

macro to edit a .txt file?

But that may screw up any space formatted tables.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version