2021-03-28 05:44:09

Hello...
I was recently editing a document I've been working on for a while, and I need to make a revision to it. I don't know how to look this up, because the best way I can describe it is with an example. I'll put it in a block quote so you won't have to read all of it once you get the general idea of how it's formatted.

Suzy: "Hi Michael!"
Michael: "Hey Suzy; were you able to make it to the magic tournament last week?"
Suzy: "Na, I had a doctor appointment and forgot about it until an hour before I had to show up."
Brad: "Ah, probably just as well; we all lost anyway."

What I'm trying to do is remove, say, both the beginning part where it says Suzy: " and the ending part which is " (quote) at the same time. I could do separate removals for Suzy: " and " (quote), but if I do that, it will remove the ending quote from both Michael and Brad which I don't want. I tried typing Suzy: "*" into the find box and * into the replace box, but it didn't work. If the document was that small, it wouldn't be that big of a deal. I could simply go in and manually remove the name and the ending quotation mark, and it would only be a miner annoyance. Unfortunately, it's not that small. It would take me a few hours to go in and remove everything I need to remove. If I had the feature where I could remove the beginning and end while leaving the middle, it would take me a few seconds to do it. I tried searching for how to use find and replace to remove beginning and end parts of text while keeping the middle intact, but all I got were results on how to use find and replace and none of those results had what I was looking for. I'm wondering if I could use regular expressions to do this, and if I could it would be a huge convenience because I'm looking to do something similar with an NVDA dictionary as well. Unfortunately, I'm not good with regular Expressions, and I don't know if notepad Plus Plus can use them either. Does anyone have any tips on these issues?

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER

2021-03-28 06:02:27 (edited by Jeffb 2021-03-28 06:03:28)

Can't you have it get rid of the names with colons after it? That should only get rid of the names at the beginning.

Kingdom of Loathing name JB77

2021-03-28 06:16:13

That's the thing though, I don't want it to get rid of all the names in that example. Only on the lines where Suzy is talking. Plus, this is just an example.

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER

2021-03-28 06:26:08

I don't think it can do that. It can get rid of names with different punctuation. But other than that you'll have to do it by hand.

Kingdom of Loathing name JB77

2021-03-28 08:33:42

Do you know any programming? You can throw something together pretty quickly if you know any. I'd probably use flex, but there are other options.

Also, find and replace in what, exactly? You don't really say, so it's kind of hard to tell you whether it would work or not. I'm also kind of unclear just exactly what you want to do. Do you want to remove *just* the name and quotes, so (Suzy: "Hi Michael!") becomes (Hi Michael!), or do you want to remove the entire block of text, i.e. everything Suzy speaks?

Anyway, if whatever you're using is doing generic find and replace, no, it won't do it. But that's why the gods gave us regexp, also to confuse us and make us cry. This one shouldn't be *too* complicated though, so you could probably manage it with a bit of tinkering.

_____________________________
"rabbid dog  aggressive  attitude" since 3035. THE SYSTEM IS TRAP!

2021-03-28 09:09:03

I built a python script that edits the indentation and adds text to the beginning and end of lines, so if you know very basic stuff, even in bgt you could make something that will help you do this.

2021-03-28 12:09:11

You want groups:

(Suzy|Michael|annoyance)[:] ")([^"]+)"

The first group (bits inside the parentheses) should yield the name: " bit, and the next group should give you what they say. The last bit (which I didn't bother grouping), is simply the closing quote.
The [^"] formation says "anything except the ^ symbol". Putting a + sign after it says "Where is occurs 1 ore more times". Replace wtih * if you want 0 or more, so it will support lines like Johnny: "".

HTH.

-----
I have code on GitHub

2021-03-28 16:12:40

if whatever programme you use lets you put wildcards on find and replace than yes

2021-03-28 16:55:10

I wish I could understand you Chris, but sadly I don't know enough programming to be able to pull this off by writing a script to do this for me.

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER

2021-03-28 19:32:10

@5, flex/bison is overkill for something like this. Plus, Flex only generates lexers, not parsers. But either way, a parser generator is completely overkill for something so simple like this.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2021-03-28 21:20:55

@dan_gero I would pull that document up in notepad++ and then use the find and replace dialog there, switch the mode radio button to regular expression, and then copy in what he put in for post 7 in to the find box. In the replace box, use \2 which takes everything from the second large group of parentheses matched which in this case is the text after the first quote.

I like to sleep, Sleep is good,
This is how I do it: Lie on a nice warm cozy bed, and dream dreams about how to rule the world!
Follow @TheGreatAthlon5 on twitter for humorous facts and game updates!
If you like my posts, thumb me up!

2021-03-28 21:38:23

I can't get this to work, so now I feel really dumb for not being able to figure this out. I pasted (Suzy|Michael|annoyance)[:] ")([^"]+)" into the find box and \2 in the replace box, but alas, no dice. I know I'm not doing it right, but I can't figure out why it's wrong.

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER

2021-03-29 18:47:14 (edited by Dan Gero 2021-03-29 18:48:26)

Update: I figured it out, and I'm gonna show you how I did this so nobody else will be confused.
For reference, let's bring back the above quote.

Suzy: "Hi Michael!"
Michael: "Hey Suzy; were you able to make it to the magic tournament last week?"
Suzy: "Na, I had a doctor appointment and forgot about it until an hour before I had to show up."
Brad: "Ah, probably just as well; we all lost anyway."

I used Notepad Plus Plus and switched the radio button to regular expressions, then I typed this into the find box.
Suzy: "(.*)"
I typed this into the replace box.
\1
Here's the end result.

Hi Michael!
Michael: "Hey Suzy; were you able to make it to the magic tournament last week?"
Na, I had a doctor appointment and forgot about it until an hour before I had to show up.
Brad: "Ah, probably just as well; we all lost anyway."

This is exactly what I was looking to do, and now after my buddy showed me these commands I know how to do it so I'm happy. Hopefully this helped someone out.

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER

2021-03-30 21:06:43

@13
Really glad you got it sorted, but I have to ask, why do you want Suzy's messages to appear without the name when you want to preserve the other names? I'm baffled.

-----
I have code on GitHub

2021-03-30 21:20:40

Happy to explain. As you guys might know, I have been working on a translation project for Shadow Line. When your named character is talking, it indicates this by just reading the words your character would say. I felt this could potentially confuse players, so I made the English version say your player name before the text. Unfortunately, I got all the way through the main story and ran into a conflict where another character says the exact same text that your character said earlier in the story, and because of that, it said your name when reading the text for that character, which could cause even more confusion and problems. As such, I had to revert back to the way it was before, which means I have to replace all lines that say ?name?: "Text" with "Text". Of course, I still have to edit lines here and there to get rid of lines that have ?name? where it shouldn't be present, but thanks to regular expressions this job has now become easier for me. Hope that clears things up a little bit.

Discord: dangero#0750
Steam: dangero2000
TWITCH
YOUTUBE and YOUTUBE DISCORD SERVER