Copy link to clipboard
Copied
I've set up the GREP rules in my document so that all the numerals in the body copy are OSF, I want to single out dimensions of things to have them ignore that GREP rule. All the dimensions look like this (3.5 × 7.5 in) or this (3.5 × 7.5 cm). At the moment I'm just using a simple \d+ to find the digits and change them. I've tried using negative lookbehinds/aheads but it either just takes one of the numbers or all of the numbers in the text. Anyone got a simple fix?
Thanks!
I've built out an example of what I described in my last post. The logic is that I add a GREP Style "Oldstyle" to change all numbers to Proportional Oldstyle. I then apply a second GREP style "NOT Oldstyle" which applies a regular number style to anything it finds in brackets which includes a decimal number, followed by an "x", followed by another decimal number and lastly followed by "in" or "cm". I ran this on your text and it works if I correctly understand what you are trying to achieve
Char
...Copy link to clipboard
Copied
I'm not necessarily a GREP hero, so someone may be able to improve upon this, but you can try Find: (\(.+?\)) Change to: (a Character style with Lining Figures set)
Or, since it's only a formatting change, a GREP Style is applicable.
Copy link to clipboard
Copied
Hi John, thanks for your answer, I've actually set it to find all digits as a GREP style within a paragraph style so short of changing the original GREP query I can't alter it using find and replace or even by changing it manually.
Copy link to clipboard
Copied
Okay, so if you add a second GREP style (the one shown above) to that paragraph style it will run after the first and set your dimensions to lining figures.
Copy link to clipboard
Copied
Is that right? I thought the first one cancelled out all others? I'll try and report back!
Copy link to clipboard
Copied
It didn't work, as far as I'm aware if you have a GREP style applying to say, numerals, then nothing can effect it. I need to alter the GREP style applying to the OSF to exclude the sections I want in lining, otherwise there's no way I can see it working.
Copy link to clipboard
Copied
Why not set the OSF as part of the paragraph styles, then make the grep use lining figures based upon the needed pattern?
Copy link to clipboard
Copied
I'm using a typeface with an expert version which has OSF but no characters.
Copy link to clipboard
Copied
I think some screenshots with invisibles on, or some copy/paste of the text that you don’t want to change would be helpful. It is all about patterns and the patterns are going to be dependent on context.
Copy link to clipboard
Copied
I did copy and paste the text I didn't want to change above, it all appears as ((number possibly with a decimal point) × (number possibly with a decimal point) in) or ((number possibly with a decimal point) × (number possibly with a decimal point) cm). What would you like me to take a screenshot of?
Copy link to clipboard
Copied
I thought that patterns such as (3.5 × 7.5 in) needed a different grep style applied than other digits?
What would be helpful is what I asked for, a screenshot with invisibles turned on showing both the text that should not change and the text that needs to change.
Or a copy and paste, such as:
Here are some numbers 1, 2 and a double digit 27 that should not change style, however I need patterns such as this (3.5 × 7.5 in) to change to a totally different grep style without affecting the previous numbers in red.
Copy link to clipboard
Copied
Okay, sorry stephen, I misunderstood, see attached, blue is to keep as OSF and orange is to change. Also attached is the GREP style in question, as I previously mentioned, I can't (although it would be a much better way of doing it) just search for the particular examples, as the old style figures are in a separate expert version of the typeface. This means I need to search for all digits excluding ones preceded or followed by a multiplication symbol. I thought something along the lines of (?<!x~<)\d+\.?\d+(?!~<x) but this didn't work.
Copy link to clipboard
Copied
OK, my first step is to try to isolate the various patterns into capture groups, with each separated by a pipe | symbol:
(\d{4}-\d{2,4})|(\d+\.\d+\Kx\d+\.\d+)|(\d+?\K\.\d+)|(\d+?)
Keep in mind that this is raw text only, without any special characters etc. The escaped parentheses characters have been removed however they are easy enough to add back in \( or \) – and the same for any white spaces... As I said this just a quick first step you may not wish to include some of the captured non-digit characters due to font differences. The capture groups can certainly be altered to highlight the entire range of characters as in your example.
Copy link to clipboard
Copied
Sounds like your constant in this situation is the multiplication symbol. Try something like this:
(\d+?\.\d+?(?= [x×]))|((?<=[×x] )\d+?\.\d+?)
This will look for either a multiplication symbol or a normal "x" character (just in case someone entered in the x incorrectly).
Copy link to clipboard
Copied
This would work if I just wanted to find them but what I actually need is to find all numbers EXCEPT them.
Copy link to clipboard
Copied
Oh, I see.
Then the best is to just set your paragraph style to use OSF under open type formats and then change the dimensions using the GREP above to not be OSF.
Copy link to clipboard
Copied
Hi Dative. If I understand correctly you can, using GREP Styles, alter all numbers as well those you don't want to alter. Have you tried applying a GREP style to all numbers and then applying a second GREP style that effectively un-alters those that you don't want to change?
What I'm suggesting is really an expansion of what John Mensinger was saying when he mentioned adding a second GREP style.
An example using fonts…
1. Default Paragraph Style applied to everything that applies the font Minion Pro.
2. Apply a GREP Style that changes all numbers to Arial.
3. Apply a second GREP Style that changes specific numbers back to Minion Pro.
Copy link to clipboard
Copied
I've tried this but, as I've tried numerous times before, the second GREP style doesn't cancel out the first. I need a specific GREP query that will find all digits excluding the bracketed dimensions.
Copy link to clipboard
Copied
I suggest changing the paragraph style, but if for some reason you are unable to do this you can try setting a nested style to go to the end of the paragraph with the OSF char style, and then a new char style applied with GREP style will trump the nested style.
Copy link to clipboard
Copied
I've built out an example of what I described in my last post. The logic is that I add a GREP Style "Oldstyle" to change all numbers to Proportional Oldstyle. I then apply a second GREP style "NOT Oldstyle" which applies a regular number style to anything it finds in brackets which includes a decimal number, followed by an "x", followed by another decimal number and lastly followed by "in" or "cm". I ran this on your text and it works if I correctly understand what you are trying to achieve
Character Style: Oldstyle
In the OpenType Features section sets the Figure Style to Proportional Oldstyle
Character Style: NOT Oldstyle
In the OpenType Features section sets the Figure Style to Tabular Lining
Paragraph Style: Body
GREP Style #1
Character Style: Oldstyle
\d+ - Any digit, one or more times
GREP Style #2
Character Style: NOT Oldstyle
\(\d+\.\d+x\d+\.\d+(in|cm)\)
\( - Opening bracket
\d+ - Any digit, one or more times
\. - Decimal point
\d+ - Any digit, one or more times
x - An actual letter "x"
\d+ - Any digit, one or more times
\. - Decimal point
\d+ - Any digit, one or more times
(in|cm) - The literal text "in" or "cm"
\) - Closing bracket
If your text contains spaces, just add these to the GREP Style definition...
To find: (3.5×7.5in)
\(\d+\.\d+x\d+\.\d+(in|cm)\)
To find: (3.5 × 7.5 in)
\(\d+\.\d+ x \d+\.\d+ (in|cm)\)
Copy link to clipboard
Copied
I understand the logic Michael and thank you for taking the time to explain it to me, what you've written there is very similar to what I had written except I'd included 'zero or more times' around the decimal points and second digits and also \s instead of space just in case people had used varying spaces.
\(\d+\.?\d?\s×\s\d+\.?\d?\s(in|cm)\)
I didn't think you could cancel out one GREP with another but that wasn't the problem, the error I was making was to do with the multiple variations of typeface, the character style was set to the expert and so had no lining version. All fixed now! Thanks for your help
Copy link to clipboard
Copied
My pleasure Dative.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now