I get regularly a document with technical data mostly numbers in rows.
I wish to replace all text which is in between these numbers, with the same amount of blanks, to keep the numbers in a row.
How can I do that?
Example: NO ELEMENTS AVAILABLE = 21 bytes should be replaced by 21 blanks.
or other example
SELENOCENTRIC ORBIT = 19 bytes should be replaces by 19 blanks
and so on.
This is a list with over 35.000 lines and about 150 text parts which I need to replace.
Thanks for your help.
Vauh
Replace text with blanks
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
It depends on what exactly you mean by a number.
If you just want to replace every character that isn't a digit, a dot, a comma or a minus sign by a space, you can use this:
If you just want to replace every character that isn't a digit, a dot, a comma or a minus sign by a space, you can use this:
If you need to distinguish between dots and commas in numbers from dots and commas elsewhere, it's a bit trickier.Find what: [^0-9.,-]
Replace with: [a space]
[X] Regular expression
Replace All
-
Vauh
- Posts: 5
- Joined: Fri Dec 07, 2007 10:17 pm
Thanks for your message.
But, unfortunately, this is not, what I want to do.
There are letters, I don't want to replace.
I put in the search option, what I wish to delete and to replace by blanks.
But, I don't want every time to put in the replace section 20 ore more times a blank using the space bar.
Example:
Search: NO ELEMENTS AVAILABLE = 21 bytes
Replace: 21 times space bar
This is what I do now!!!!!
How I can make this easier?
Thanks for your help.
Vauh
But, unfortunately, this is not, what I want to do.
There are letters, I don't want to replace.
I put in the search option, what I wish to delete and to replace by blanks.
But, I don't want every time to put in the replace section 20 ore more times a blank using the space bar.
Example:
Search: NO ELEMENTS AVAILABLE = 21 bytes
Replace: 21 times space bar
This is what I do now!!!!!
How I can make this easier?
Thanks for your help.
Vauh
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Unfortunately, you can't do this with TextPad.
But you can easily do it with a script in any of many popular free scripting languages such as Perl, Python, Ruby or Tcl. For example, you can use this Perl one-liner on the Windows command line:
But you can easily do it with a script in any of many popular free scripting languages such as Perl, Python, Ruby or Tcl. For example, you can use this Perl one-liner on the Windows command line:
Code: Select all
perl -i.bak -p -e "s/NO ELEMENTS AVAILABLE/' ' x length $&/e" filename