Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I've read a bit and found NotePad++ doesn't use "normal" regex (starting to think I'll just go back to SciTE), but here's my question:

I've got an exported list of data with some redundant data that I'm trying to clean up and convert into a good CSV for import into address books (migrating a Fax server solution, the old one is OOOOLD and so this is the best I can got for export).

The line I'm trying to remove from each entry group always starts

Entry: NAME ~

And then there is a 12 digit alphanumeric (is appears to be Hexadecimal) code that follows that is unique for each entry group. For a few entry groups there is a human-readable entry following "NAME", but these are few enough I can remove them manually, so matching them isn't a big chore.

So what I want to do is to find every line that begins with Entry: and select it all the way to the end of the line. Each entry in each group is on a separate line. Then I'll use Find & Replace to remove these lines from the list.

UPDATE: Input & Outpu

Entry: NAME ~00003193820
ShortName: ~00003193820
Owner: USRENAME
Name: John
FamilyName: John
DearName: John
Organisation: Acme 1 Corp
Via: FAX-ANY 1(555) 123-4567

Entry: NAME ~00003193820
ShortName: ~00003193820
Owner: USRENAME
Name: Sam
FamilyName: Sam
DearName: Sam
Organisation: Acme 2 LLC
Via: FAX-ANY 1(555) 890-1234

Here's two entry groups. I want to remove the lines beginning with "Entry:" from each and every group.

share|improve this question
    
Why not import into excel, do a text filter, and delete them that way. You can resave as csv – Raystafarian Feb 6 '12 at 16:21
    
That would work in this case. I'm also trying to learn how to do it in RegEx for future ability. – music2myear Feb 6 '12 at 16:28
    
please provide with input and expected output with examples – Siva Charan Feb 6 '12 at 16:29
    
@music2myear Roger that :) – Raystafarian Feb 6 '12 at 16:29
    
I'm pretty sure my question was detailed enough. I specified I needed the RegEx syntax that will work in NotePad++ to find a line beginning with Entry: but with varying end portions. In case it was not enough, I added specific examples (sanitized, of course) of the input and describe the desired output. Again. – music2myear Feb 6 '12 at 16:36
up vote 2 down vote accepted

Another option would be

^Entry: NAME .*

Which will look for lines beginning with Entry: NAME and anything after that.

share|improve this answer
    
Ok. It was the "." that I was missing. What does the "." signify in RegEx? – music2myear Feb 6 '12 at 18:47
    
@music2myear The dot (.) is a placeholder meaning "(almost) any single character". – Oliver Salzburg Feb 6 '12 at 19:00
    
@music2myear I should have explained it when I posted, usually try and be more detailed when answering. [ . ] in regex is "any character" [ * ] in regex is "0 or more of the pattern" so in english "anything or nothing up to a carriage return" – FaultyJuggler Feb 6 '12 at 21:46

Using

^Entry: NAME ~\d+$

as the search pattern seems to work as requested.

I would personally recommend matching using the \d placeholder (which matches any single digit in the range from 0 to 9) instead of a more general . placeholder. In fact, you should even make it:

^Entry: NAME ~\d{12}$

to specify that you expect exactly 12 digits in a row. This way, if an entry might contain something you didn't expect, you don't replace it by accident.

If the string turns out to be in hexadecimal notation, you might use:

^Entry: NAME ~[0-9a-fA-F]{12}$

Please note that I didn't check if the last 2 examples work properly in Notepad++, but to my knowledge, that's all pretty basic syntax.

share|improve this answer
    
I was going to say, matching only numeric characters wasn't going to do me much good... – music2myear Feb 6 '12 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .