Copy link to clipboard
Copied
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?
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)
Copy link to clipboard
Copied
^.+?\K\.
From the beginning of the paragraph, select the first period but not the text before it.
I think. It worked for me.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Thanks for your help but this did not work for me.
Copy link to clipboard
Copied
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?


Give a bit more (and good) examples for testing, please.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This should be no problem with the grep above - equal if in the same text frame or in several text frames.


Can you upload an example file without private informations on a hoster of your choice and link here (eg dropbox or xup.in)?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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???
Copy link to clipboard
Copied
Sorry about that, I've got hard returns after each paragraph with space after. I've included a new screenshot.
Copy link to clipboard
Copied
![]()
These all are returns.
Copy link to clipboard
Copied
But only a last question: What InDesign version do you use?
Seems to be an older version - or not?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
And what if the next sentence begins with digit?
Just for fun - a bit different approach:
^[^.?!]+\K\.(?!$)
Copy link to clipboard
Copied
Hi winterm
"\w" includes digits - and "." too
Copy link to clipboard
Copied
pixxxel schubser wrote
"\w" includes digits - and "." too
hi,
I mean this:
Biology. 25 scientists did a research blah blah....
Copy link to clipboard
Copied
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....
Try it. Both greps are also working with " Biology. 25 …"
Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
https://forums.adobe.com/people/pixxxel+schubser schrieb
…
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 …?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now