Replace text between 2 characters
-
Hello,
I want to replace all the text in my text file with a certain thing
For example, if we take the text:
John sat on the mat and said"the fat cat ate the rat"and matt said"what about a bat"presumptuously.
I want to make it so the text between the each group of speech marks is replaced with the exact same thing except with spaces at the start and end.
John sat on the mat and said “the fat cat ate the rat” and matt said “what about a bat” presumptuously.
Of course, the text file is much larger and I would hate to go through it all doing this manually.
-
Hello, @comic_sans-criminal2 and All,
No problem ! But I noticed that your “Before” text contained regular Quotation Marks (
\x{0022}), whereas your “After” text contained Left Double Quotation Marks (\x{201C}) and Right double quotation marks (\x{201D})Refer to http://www.unicode.org/charts/PDF/U2000.pdf
Anyway, the regex S/R , below, will match three
3characters !
So :
-
Open the
Replacepanel (Ctrl + H) -
Select the
Regular expressionsearch mode -
Tick the
Wrap aroundoption -
Type
(?-s)["“](.+?)["”], in the Find what: zone -
And, in the Replace with zone :
-
Write
\x20"\1"\x20, if you need regular quotation marks -
Use, instead,
\x20“\1”\x20, if you prefer stylistic quotation marks
-
-
Click on the
Replace Allbutton
Voilà !
Best Regards,
guy038
-
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login