Skip to main content
Known Participant
August 28, 2020
Answered

add an exclamation point at the end of each character style by grep

  • August 28, 2020
  • 3 replies
  • 1205 views

I have a bit of a complex question in grep. I try to add an exclamation point at the end of each character style. I found a string on the internet that recognizes the end of a character style (attached) but I can't add the exclamation point. Thanks for the help,

This topic has been closed for replies.
Correct answer Manan Joshi

Sorry, I did not get notified about the reply to this post, hence did not reply earlier. For the first question I did not quite understand what you are trying to do, please share the code changes you made and the screenshots of what you start with, what you want to get, and what happens incorrectly. This will make it easier to answer.

For the other query, I would suggest creating a new post, that would provide the query a wider audience. I have not worked extensively with Footnotes so it's better to get opinion of other forum experts.

-Manan

3 replies

Manan JoshiCommunity ExpertCorrect answer
Community Expert
August 30, 2020

Sorry, I did not get notified about the reply to this post, hence did not reply earlier. For the first question I did not quite understand what you are trying to do, please share the code changes you made and the screenshots of what you start with, what you want to get, and what happens incorrectly. This will make it easier to answer.

For the other query, I would suggest creating a new post, that would provide the query a wider audience. I have not worked extensively with Footnotes so it's better to get opinion of other forum experts.

-Manan

-Manan
aviel222Author
Known Participant
August 30, 2020

Attach what I need.
many thanks!!!

 

https://www.dropbox.com/s/5a5jwiuppmg0bvu/www.zip?dl=0

 

 

Community Expert
August 28, 2020

The reason I think is that finding for format does not create a capturing group, so $1 does not point to anything, and hence it's taken literally. I don't think this can be handled using just the UI interface. I have put a script that should help you.

 

app.findGrepPreferences = null
app.findGrepPreferences.appliedCharacterStyle = "מודגש"
var result = app.documents[0].findGrep()
for(var i = 0; i < result.length; i++)
	result[i].contents += "!"
	
app.findGrepPreferences = null

 

-Manan

-Manan
aviel222Author
Known Participant
August 28, 2020

Excellent! Thank you!
I have another request from you if you can help me that is also related to the script, maybe something a little more complex. I would be happy if you help me. Write to me if you agree

Community Expert
August 28, 2020

If it's something that would need a solution developed then you can drop me a DM, we can connect and discuss it further. If it's something that needs some ideas and is not related to this query feel free to post a new query on the forum and I or someone from the community would surely pitch in with their comments.

-Manan

-Manan
Community Expert
August 28, 2020

I am not able to download the pdf that you attached. I am not sure if grep styles would work here, grep styles don't allow adding in content as far as I know. What you need, in my opinion is Grep find/change. It should be simple, in the "find format", add the character style to find and in the "change to" use $1!

If this is not what you need, then paste some screenshots of how your document looks and how you want it to be changed.

-Manan

-Manan
aviel222Author
Known Participant
August 28, 2020

Really $1!
Was supposed to work
But it's not working.
Attach open file 

 

https://www.dropbox.com/s/h3djhgsfw5oy00k/q%20Folder.zip?dl=0

 

 

 

FRIdNGE
August 30, 2020

I don't know who wrote this Grep Code but no interest to make it so complex!

Just:

Find: .+

Replace by: $0!

 

(^/)  The Jedi

 

Btw: your code doesn't work just because, using "(?<!.).+(?!.)", it includes 2 looks that border a ".+"

use the Replace by: "$0!" to make it work.