Skip to main content
Inspiring
June 12, 2023
Answered

Grep Question: Command to find word then go to end of paragraph to insert asterisk

  • June 12, 2023
  • 2 replies
  • 1064 views

Can you use GREP to find a word (example "baseball") then go to the end of the paragraph and insert an asterick?

Before
Baseball is a sport played between two teams.
It is a bat-and-ball game.

 

After

Baseball is a sport played between two teams.
It is a bat-and-ball game.*

This topic has been closed for replies.
Correct answer FRIdNGE

Thanks, FRIdNGE but that just added "(^/) to the end:

Baseball is a sport played between two teams.

It is a bat-and-ball game.(^/)

 

NEVERMIND! LOL!! I didn't realize (^/) is part of your signature!!!


(^/) is just my signing on Forums! 😉

 

Find: (?s)Baseball.*\K$

Replace by: *

 

or

 

Find: Baseball\X*\K$

Replace by: *

2 replies

Community Expert
June 12, 2023

Find:

(Baseball|baseball)(.+)

Change to:

$0*

Inspiring
June 12, 2023

Thank you, Jeffery_Smith!
I just realized that both solutions just go to the end of the sentence. Is there a way to go to the end of the story?

Inspiring
June 12, 2023

(^/) is just my signing on Forums! 😉

 

Find: (?s)Baseball.*\K$

Replace by: *

 

or

 

Find: Baseball\X*\K$

Replace by: *


LOL! Thanks FRIdnge!! You're the best and I appeciate the help!

FRIdNGE
Inspiring
June 12, 2023

Find: Baseball.*\K$

Replace by: *

 

(^/)  The Jedi

Inspiring
June 12, 2023

Thank you, FRIdNGE!! Much appreciated.