Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
9

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

Explorer ,
Jun 12, 2023 Jun 12, 2023

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.*

TOPICS
How to , Scripting
799
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jun 12, 2023 Jun 12, 2023

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

 

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

Replace by: *

 

or

 

Find: Baseball\X*\K$

Replace by: *

Translate
Guide ,
Jun 12, 2023 Jun 12, 2023

Find: Baseball.*\K$

Replace by: *

 

(^/)  The Jedi

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2023 Jun 12, 2023

Thank you, FRIdNGE!! Much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2023 Jun 12, 2023

Find:

(Baseball|baseball)(.+)

Change to:

$0*

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2023 Jun 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 12, 2023 Jun 12, 2023

(?s)Baseball.*\K$

 

(^/)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2023 Jun 12, 2023

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!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2023 Jun 12, 2023

Now I see you can just add the asterisk to the change. The first time I tried, it didn't work:
Find: (?s)Baseball.*\K$
Change: *



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 12, 2023 Jun 12, 2023

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

 

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

Replace by: *

 

or

 

Find: Baseball\X*\K$

Replace by: *

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2023 Jun 12, 2023
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines