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

GREP: How to replace the first period in a paragraph using Find/Change?

Community Beginner ,
Dec 17, 2018 Dec 17, 2018

I am new to GREP and I really enjoy learning this time saving feature in InDesign. I was wondering if I had a long document that had definition paragraphs formatted like below, how could I find and replace the first period with an em?

Before:

Biology. the study of living organisms, divided into many specialized fields that cover their morphology, physiology, anatomy, behavior, origin, and distribution.

After:

Biology the study of living organisms, divided into many specialized fields that cover their morphology, physiology, anatomy, behavior, origin, and distribution.

I have tried the code ^\. which I thought would target the first period in the paragraph but these doesn't seem to work and I can't figure out way or figure out the correct way to code this. Any suggestions?

3.2K
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

Community Expert , Dec 17, 2018 Dec 17, 2018

too few examples for sufficient answer.

But try:

^\w+\K\.(?=\s\l)

Will find the dot after the first word in a paragraph (which is followed by space and lower case letter)

Translate
Participant ,
Dec 17, 2018 Dec 17, 2018

^.+?\K\.

From the beginning of the paragraph, select the first period but not the text before it.

I think. It worked for me.

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Thanks so much for the help! This sorta worked but for some reason it is finding the first period in  every other paragraph. I thought this would be simple but it seems that what I am trying to do is more advance GREP based on the looks of the code.

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 ,
Dec 17, 2018 Dec 17, 2018

too few examples for sufficient answer.

But try:

^\w+\K\.(?=\s\l)

Will find the dot after the first word in a paragraph (which is followed by space and lower case letter)

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Thanks for your help but this did not work for me.

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 ,
Dec 17, 2018 Dec 17, 2018

Why not?

Do you really have a lower case letter after the dot/space behind the first word?

Do you really have only one word at the beginning?

aaa1.png

aaa2.png

Give a bit more (and good) examples for testing, please.

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

It did not repeat for me. It found the period in only the first paragraph. Sorry but I don't have any more examples because I am doing this for learning purposes, I don't have an actual document but I am testing this in inDesign with the text the same as in your screen capture but I need it to find the first period of each paragraph or in this case instance of the duplicated paragraph. The code ^.+?\K\. worked but only for every other paragraph and I don't understand enough about the GREP to understand why this is the case.

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 ,
Dec 17, 2018 Dec 17, 2018

Why does this not work for you?

What is your expectation?

Are you looking for a solution that you can “replace all” without eyeballing each find/replace to qualify that subsequent paragraphs that do not meet your criteria are not affected?

As has been mentioned, there may not be enough info to go by, the more info you provide the better the responses.

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

I am learning GREP and I was trying to think of situation were I may need to use it for my work. In my example I envisioned that if I had a long document with multiple definitions formatted with a period between the definition term and definition text, if needed I would be able to change only the first period in each paragraph using Find/Change and replace it with an em dash. My expectation is to be able to isolate the first period and change it to an em dash across multiple paragraphs within an inDesign document.

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 ,
Dec 17, 2018 Dec 17, 2018

This should be no problem with the grep above - equal if in the same text frame or in several text frames.

aaa3.png

aaa4.png

Can you upload an example file without private informations on a hoster of your choice and link here (eg dropbox or xup.in)?

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Thanks so much for your help so I tried it again and it is doing ever other paragraph. I feel like I am screwing this up somehow. I've included a screenshot. Capture.PNG

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 ,
Dec 17, 2018 Dec 17, 2018

Thx for your screenshot, but I can't see the last hidden character after your sentences.

Are you sure that you really have a return – and not a hard return???

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Sorry about that, I've got hard returns after each paragraph with space after. I've included a new screenshot.Capture-2.PNG

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 ,
Dec 17, 2018 Dec 17, 2018

These all are returns.

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 ,
Dec 17, 2018 Dec 17, 2018

But only a last question: What InDesign version do you use?

Seems to be an older version - or not?

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Yes it is, CC 2015, I think I have the newest version on my home computer. I'm guess that the problem is that we need to upgrade.

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
Mentor ,
Dec 17, 2018 Dec 17, 2018

And what if the next sentence begins with digit?

Just for fun - a bit different approach:

^[^.?!]+\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
Community Expert ,
Dec 17, 2018 Dec 17, 2018

Hi winterm

"\w" includes digits - and "." too

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
Mentor ,
Dec 17, 2018 Dec 17, 2018

pixxxel schubser  wrote

"\w" includes digits - and "." too

hi,

I mean this:

Biology. 25 scientists did a research blah blah....

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 ,
Dec 17, 2018 Dec 17, 2018

myishag26823989

CC2015 should be ok. But I didn't understand why only every second paragraph will be found in your screenshots.

Maybe something is wrong in your document. Please restart your computer and try it again with a new InDesign document.

winterm  schrieb

https://forums.adobe.com/people/pixxxel+schubser   wrote

"\w" includes digits - and "." too

hi,

I mean this:

Biology. 25 scientists did a research blah blah....

winterm

Try it. Both greps are also working with " Biology. 25 …"

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Yes I am very confused too but now I can clearly see that your answer was correct and the problem is on my end. Thanks so much for your help again!!

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
Mentor ,
Dec 17, 2018 Dec 17, 2018

pixxxel schubser  wrote

Try it. Both greps are also working with " Biology. 25 …"

Huh, hate to post in an already answered thread...

Just to be clear: are you saying, this regex

^\w+\K\.(?=\s\l)

finds a dot after Biology

in this text:

Biology. 25 scientists did a research... blah blah.

Really?

--

Please treat me right, I'm not questioning 'correct' answer, it's perfectly ok in OP's given samples.

But you can't catch a digit when you look for lowercase letter...

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 ,
Dec 17, 2018 Dec 17, 2018

Thank you for your answer winterm

You are right. And that is very good.

But see the other posts

pixxxel schubser​ wrote:

You can also try

^\w+\K\.(?=.)

And I meant

You can also try

^\w+\K\.(?=\s\w) does also work. (and dozens of other combinations)

Sorry for confusion.

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 Beginner ,
Dec 17, 2018 Dec 17, 2018

Just an addition to my previous post, I repeated the find/change with the same GREP ^\w+\K\.(?=\s\l) and it replaced the other two periods, same for ^.+?\K\. so now I am really confused as to why I have to do it in two steps. Maybe it is my work's inDesign. I'm going to try it on my home computer tonight. Thank you everyone for your 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
Community Expert ,
Dec 26, 2018 Dec 26, 2018
LATEST

https://forums.adobe.com/people/pixxxel+schubser  schrieb

aaa4.png

Can you upload an example file without private informations on a hoster of your choice and link here (eg dropbox or xup.in)?

Can you upload an example file …?

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