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
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

696 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