Copy link to clipboard
Copied
Hello,
I need to set the numbers after people's names in superscript. There is no space between the name and the number.
Ex:
"George1 lorem ipsum and George4 lorem ipsum went to the park."
*So the 1 and 4 would be set in superscript.
I have created a character stylesheet for the superscript.
Within the paragraph style I'm trying to set a GREP to select the numbers that come after the names to be styled.
I have the following:
(?=\w)\d(?=\s)
This works to some extent, but I have found issues where strings of numbers are also being effected. For example, in "25 February 1796," the "5" in "25" is being targeted, but "1796" is not effected at all.
I tried changing the grep to the following, but that didn't seem to select anything.
(?=\u\l)\d(?=\s)
Any help appreciated.
You're positive lookbehind in second example was off. Try this:
(?<=\u|\l)\d(?=\s)
Copy link to clipboard
Copied
You're positive lookbehind in second example was off. Try this:
(?<=\u|\l)\d(?=\s)
Copy link to clipboard
Copied
Thank you very much!
So, the only difference was the "|" bar character between "\u" and "\l"?
What does the bar character signify?
Copy link to clipboard
Copied
You also were missing the < for the lookbehind. The | indicates either/or. Either a lowercase or uppercase letter precedes it. Some others better at GREP might have a better solution, but those were the two main differences. Your example was not a positive lookbehind.
Copy link to clipboard
Copied
Speaking of the | (bar), if you knew the names in advance and there weren't too many you could use
(?<=George|Mandy|Poe)
for the lookbehind. This would ensure you didn't accidentally match something like "Section A1".
- Mark
Copy link to clipboard
Copied
Edit: Brian's answer is better because it targets letters of names better than mine, which might get confused by punctuation, for example. I'll leave mine here for the record though. 🙂
Hi @KF Design, I'm no expert on regular expressions, but this worked for me in a basic test:
[^\d\s]+\K\d(?=\s)
It says find one or more characters that aren't digits or whitespace (then \K means ignore that after matching it), then find a *single* digit, followed by a whitespace.
- Mark
Copy link to clipboard
Copied
Thank you very much for your reply!