Urgent Find and Replace Help Needed!


#1

Hi,
I have never used Atom or any text editor, so even how to import or select document to edit is scary. I need a step by step to save me. I have about 1500 pages of text that I can import into TextEdit or anything else. The document is filled with Questions and Answers indicated by:

Q: 01
What is . . . ?

A: 01
It is!

Q: 02
xxxxxx

A: 02
xxxxx

This goes on for about 3000 or so Q and A’s.

I’d like to replace all of the Q: # and A: # with a blank line. In the end, I want only text so Text to Speech on my MacBook can read me the questions and answers without saying, “A: 459” or Q: 1299."

It would take me a week to do manually.
Any help is appreciated.
Tommy


#2

Here’s a GIF, instructions follow (click on the GIF if it doesn’t animate):

  1. Open the Find-and-Replace pane with Cmd+F on OS X or Ctrl+F on other platforms
  2. Ensure that Regex Mode is enabled by pressing the .* button so the Regex text shows
  3. Enter in the Find box: (Q|A): \d+
  4. Ensure nothing is in the Replace box
  5. Click the Replace All button

#3

Beaten, and with a GIF as well. You’re putting us all to shame! I’d put anchors in the regex (^(Q|A): \d+$) just in case.


#4

Got it on the second try. Many thanks!! Fantastic!! You saved me countless hours.

Forgive me for asking for more help . . .

I’m left with a large gap of 2, 3, or more blank lines in between my text. I’d like to reduce that down to 1 blank. Can I do that?


#5

This is beginning to sound like homework … but ok …

Find: \n{3,}
Replace: \n\n


#6

Sorry my brother. I’m a teacher . . . that explains the hw. Much appreciated. ;-).


#7

What I meant was that sometimes students get assigned homework and then rather than doing it themselves, they go to places like Stack Overflow and get the answer. Your posts were following the same generally abstract but with just enough detail to give it a realistic framework pattern that teachers’ homework assignments follow, so I assumed you were a student cheating themselves of a proper education :wink: Glad to hear I was wrong :grinning:


#8

Oh, I get it. No, I’m actually making lesson plans. I created Q+A’s in a flashcard format called Flashcard Hero. Then I realized the advantages of using Speech to Text for my ESL students (and when I have a sore throat, which is often in Asia) and needed to covert the Flashcard Hero to text. I exported to PDF and then converted to RTF, but needed to get rid of all of the Q+A numbers. You’ve been a huge help. I know my way about a Mac and many apps, but this is new to me. I need to move away from Word. It’s a bloated, convoluted mess that crashes all the time. If I can use a basic text app and master this fine tool . . . I think it would be much better. Thank you very, very much!!


#9

Haha … just found this when searching for information on Flashcard Hero:

http://flashcardhero.com/blog/interview-tommy-zai-on-teaching-english-in-china/

Let us know if you need any more help!


#10

Yep!! That’s me!! Flashcard Hero is a cool app. This particular deck has 3400 cards. So, to edit one by one is overwhelming. I also picked up a really cool Text to Speech voice from CereProc. They have some realistic, non-robotic voices with dialect. I chose the American, naturally. :wink:

I really appreciate your help. Anything that makes my job easier is wonderful. The air quality in China is horrible, and I often have a sore throat. Being able to convert to text and then edit will allow me to use Text to Speech here and there to give my tattered vocal chords a break.

What app do most Atom users use for for text?

Word, at least Word for Mac, is a nightmare.


#11

I followed the steps from your excellent GIF and used:

Find: \n{3,}
Replace: \n\n

I didn’t notice any changes. Did I mess something up?

\i0 in New York City.





In 1930.


#12

Did you make sure that the Find and Replace panel showed the Regex option as enabled?

For example, the settings above should convert this:

foo





bar

To this:

foo

bar


#13

Before I try again, I should probably back track . . . I may have done something wrong with the first find and replace . . . (Q|A): \d+
Many of the words became connected, e.g.,

, calledbrief therapy,in

Note: The huge text file I’m working on today is my study material to help me pass the National Therapist Exam. My job overseas is to provide ESL and counseling to “at risk” teens, i.e., “troubled kids.” Straightening this material out will greatly help me keep my certifications and licenses current. The ESL lesson plan material is usually only 2 or 3 pages per lesson, which should be easier to work with.


#14

Yeah, I think you did something wrong :grinning:

  1. Make sure the label “Regex” shows up
  2. By pressing this button

Regex or Regular Expressions is a special language for matching patterns of text. The pattern ^(Q|A): \d+$ (the better one suggested by @postcasio) essentially means:

  • ^ — Match the beginning of a line
  • (Q|A) — Match a Q or an A
  • : — Match a colon (since there is a space after the colon, it will also match one and only one space character)
  • \d+ — Match one or more digits, i.e. 0-9
  • $ — Match the end of a line

Because regular expressions are so specific, you have to be sure you typed them exactingly. Extra characters or typos can significantly change the meaning of what you entered.


#15

Continued thanks. You’ve been extremely patient . . . much appreciated. I’m clueless. This is a new world for me, but I see lots of potential . . . I want to finish a textbook for teaching ESL a new way, and Atom would be such a help (I’ll be sure to do some learning first). I’ll grab a bite and carefully give the above a go.


#16

Like this? I clicked Replace All, but nothing happened.


#17

Oh, I think I see what’s happening. You’re trying to edit stuff you’re saving in Rich Text Format. Atom doesn’t natively understand that format, it only understands plain text. But it appears that it’s ending up with roughly the right things … it’s just that my second pattern and replacement wasn’t designed to work with Rich Text. I’m not sure I know enough about Rich Text to design a better one though :frowning:

It looks like blank lines in RTF still contain a single backslash, so you might try this:

Find: \n(\\\n){2,}
Replace: \n\\\n


#18

Can I convert to plain text before dragging into Atom?


#19

If you’re talking about Word, yes:

http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/copy-text-from-a-word-document-as-plain-text/e3fa195c-04f0-43b7-a50e-b13cbc757f73

I don’t know about Flashcard Hero.


#20

I cannot reply . . . over the limit, but it worked!!! By converting to plain text and then pressing “Keep Waiting” when the “not responding” appears worked. Then, I removed all the blank lines. PERFECT!!

Many thanks!!

May I ask, what text app do you guys use? I assume if someone has the text editing down, they want the freedom to work in an app that is plain text. I doubt you guys are using Word. I’m on a Mac and of course have TextEdit, but . . .