Solved

Regexp and Textpad -- A way to remove all characters but 0-9 and then another to remove any not 10 in length?

Posted on 2013-02-04
5
585 Views
Last Modified: 2013-02-05
So I am typically using textpad which is a pretty good editor. I have alot of lines that need all characters but 0-9 removed (and the newline obviously per line). Is this possible?

The last thing I was wondering is if regexp can also per line, delete lines that aren't 10 in length total. I don't think this part is possible and I'll have to plug it into a database that can take some arguments (mysql) but maybe someone has an idea for that.

Thanks!
0
Comment
Question by:Valleriani
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:tel2
ID: 38852780
Something like this, perhaps Valleriani?

# Remove all non-digits
s/[^0-9]//g

# Delete lines not 10 long
s/^.({0,9}|{11,})$//
0
 
LVL 12

Expert Comment

by:tel2
ID: 38852846
Or you might have to do it this way, which works in Perl, but I don't know TextPad:
    s/[^0-9\n]//g
    s/^.{0,9}\n//
    s/^.{11,}\n//

I suggest you just try the 1st line of the above, first, see if that works, then add the 2nd line, see if that works, then add the 3rd.
Report back if you have problems, showing exactly what regex lines you're using.
0
 
LVL 7

Author Comment

by:Valleriani
ID: 38852980
Hmm, I've tried them all now but I can not get the regexp to work in Textpad. Do you perhaps have another editor that works in windows that would work with large files/your regexp?

I know something like this would work in regexp

Find What:  ^\(.\{10\}\).*
Replace With:  \1

which would find any lines greater then 10 characters and trim it. Don't know if that helps anything though.

Thanks!
0
 
LVL 12

Accepted Solution

by:
tel2 earned 500 total points
ID: 38853079
Hi Val,

No, I don't know of such regex editors for Windows, but I expect there will be some.  But is file size really a problem here?

The last regex you gave above looks as if it would just trim any chars after the 1st 10, which doesn't seem to be what you asked for.

What happens when you take my regex 1st line, and do this:
    Find What:  [^0-9\n]
    Replace With:  
Note the "Replace With" field is empty.


s/[^0-9\n]//g
0
 
LVL 7

Author Closing Comment

by:Valleriani
ID: 38854450
That does work, thank you!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help decoding the following expressions 1 39
CD-RW/DVD-ROM DRIVE 3 44
Regex HELP 2 23
REXEX help Part 2 2 23
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video shows how use content aware, what it’s used for, and when to use it over other tools.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question