Copy link to clipboard
Copied
Sorry to bother, but I'm still struggling with GREP! I need an expression that superscripts the numbers at the start of a string of references - for example:
1Princess Margaret Hospital, Toronto, ON, Canada; 2University of Manitoba, Winnipeg, MB, Canada; 3London School of Economics, London, UK; 4Hospital Universitario 12 de Octubre Madrid, Spain.
The references need to remain a single line, each reference separated by a semicolon, and the digits can typically include up to 2 characters. As in my example, the names can include digits at times, so those would have to be excluded from superscripting. Help!
Copy link to clipboard
Copied
I can make this work with two expressions aaplied as GREP styles separately, but not as a single expression that catches all cases.
^/d+ catches the initial digit, and (?<=; )\d+ catches the ones after.
Copy link to clipboard
Copied
Hi.
^/d+ isn't catching the first digit for me, but if I put parenthases around the caret, it works - not sure if that will create other issues, but if works for now! Thanks Peter
Copy link to clipboard
Copied
It's a typo: the slash should be a backslash: ^\d+
Copy link to clipboard
Copied
OOOPS.
Thanks, Peter
Copy link to clipboard
Copied
A typo on my part caused a single expression to work:
((; \K)|)\d+
No idea why that works though.
Copy link to clipboard
Copied
😄 as long as it does!! Thanks again.
Copy link to clipboard
Copied
Still need the two-style solution as this single one also catches the number 12 in the Spanish hospital title
Copy link to clipboard
Copied
In that case use
((; \K)|)\d+(?=\u)
which stipulates that the number should be followed by an upper-case letter.
Copy link to clipboard
Copied
@Peter Kahrel any idea why ^\d+|(?<=; )\d+ doesn't work? For me it only captures the first number after the ; and nothing else.
Copy link to clipboard
Copied
I had to put parentheses around the first caret - that worked for me, anyway
Copy link to clipboard
Copied
OK, That's pretty strange to my way of thinking. It doesn't work if you put parentheses around the whole ^\d+
Copy link to clipboard
Copied
I've no idea. I tried that one, in fact. So I don't know why this one doesn't work, and I don't know why the one I hit on accidentally does.
Copy link to clipboard
Copied
A grep style in a paragraph style applying a character style with superscript works also.
\d+(?=\u)
OR
\d{1,2}(?=\u)
OR (if there are lowercase letters starting the name)
\d+(?=\u|\l)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now