-
1. Re: GREP + Capital Letters
Manish-Sharma Aug 25, 2013 10:11 PM (in response to HSGROW_HK)Hi HSGROW_HK,
Use the below string and that should help.
\u+\b
Thanks
Manish
-
2. Re: GREP + Capital Letters
HSGROW_HK Aug 25, 2013 10:49 PM (in response to Manish-Sharma)Hi Manish,
Thanks for the tip. It worked, much appreciated. Out of interest the \u+ looks for uppercase and according to google the \b is a backslash. How does backslash work in GREP?
-
3. Re: GREP + Capital Letters
Manish-Sharma Aug 25, 2013 10:55 PM (in response to HSGROW_HK)\b is the word boundary and not the backslash, \\ is what search backlash character.
Here is the break up
\U :- Any uppercase letter
+ :- repeat one or more times
\b:- in the word boundary
-
4. Re: GREP + Capital Letters
pkahrel Aug 26, 2013 1:05 AM (in response to Manish-Sharma)\u+\b matches single capitals too, which you probably don't want. Use \u\u+ to match strings of two and more capitals. No need for the \b.
Peter
-
5. Re: GREP + Capital Letters
P Spier Aug 26, 2013 2:28 AM (in response to HSGROW_HK)HSGROW_HK wrote:
Hello,
I have a number of acronyms in a book and was wondering if there is a way to use GREP to locate all the Acronyms i.e. NASA, LASER and so on so that I can apply a specific character style (coloured small caps).
The locating is no problem, but your character style won't convert uppercase to small caps unless the acronyms were typed in lowercase and the "All Caps" ornamentation was used. Glyphs enterd as uppercase will remain uppercase when small caps are applied, but lowercase will change.
Find change can change a specific uppercase glyph to lowercase through substitution, but you can't use wildcards to find "any" glyph and then change it's case to the same character randomly, so I think you really need a script to do what you want. Perhaps Peter Kahrel is still watching...
-
6. Re: GREP + Capital Letters
pkahrel Aug 26, 2013 3:45 AM (in response to P Spier)Well, the op said it worked for him.
-
7. Re: GREP + Capital Letters
P Spier Aug 26, 2013 3:49 AM (in response to pkahrel)Yes he did, but I wonder if it worked completely.
-
8. Re: GREP + Capital Letters
HSGROW_HK Aug 26, 2013 3:57 AM (in response to P Spier)Hello Peter and Peter,
Originally, I did post that it worked, you are both quite correct. What I failed to realise is what Peter Spier had highlighted. In order to test I changed fonts and tried again, and CAPITALS remained as CAPITALS and lower case became SMALL CAPS (Please forgive, I'm not shouting)
So I think it must have been a particular font that worked with \u+\b and \u\u+
I would appreciate your help Peter Kahrel if you wouldn't mind. Thank you.
-
9. Re: GREP + Capital Letters
pkahrel Aug 26, 2013 5:00 AM (in response to HSGROW_HK)Here you go:
app.findGrepPreferences = null; app.findGrepPreferences.findWhat = '\\u\\u+'; var caps = app.documents[0].findGrep(); for (var i = caps.length-1; i > -1; i--){ caps[i].contents = caps[i].contents.toLowerCase(); caps[i].appliedCharacterStyle = 'Acronym'; }In the one-but-last line, replace Acronym with the name of the style you use.
Peter
-
10. Re: GREP + Capital Letters
HSGROW_HK Aug 27, 2013 6:40 AM (in response to pkahrel)Hi Peter,
This may seem daft, but I tried to run this script (copy paste into Apple script) and drop into the appropriate folder - but it was a no-go. I have most likely done something wrong. This is my first time using scripting of this nature.
-
11. Re: GREP + Capital Letters
P Spier Aug 27, 2013 6:58 AM (in response to HSGROW_HK)I'm the other Peter, but I know the answer. This is javascript, not applescript. You need to save it as plain text with a .jsx extension and put it in the Scripts Panel folder.
-
12. Re: GREP + Capital Letters
HSGROW_HK Aug 27, 2013 7:19 AM (in response to P Spier)Thank you Peter Spier!




