Reputation: 23
I am currently trying to format some articles in a catalog. I am doing this using GREP in a paragraph style that's applied to the articles. My problem is that the numbers have so many special situations.
The basic number is PR-1234 (4-8 characters after „PR-“)
My GREP code to format this number and the cases down below looks like this right now. it works in some cases...
(?<=^VAR-)(\w+)-(\w+)|\w+(?=/s|$)
However, I also need to consider all of the below cases. In every case, the "PR" needs to be in regular font and the parts afterwards (except "to" and ",") need to be bold.
PR-12345-ABC, PR-12345-CD
PR-1234D-11-AB
PR-1234DS-12345D
PR-12345D-1
PR-12.34.5
But that's not all! What makes it complicated is that in cases like below, all of the triple-or double digits need to be bold and italic.
PR-12345D-012LS, -13LS, -014LS, -15LS
PR-1234L-01, -02, -03
PR-12345M-02XS to -07XS
PR-1234-01 to -12
What can I try next?
Upvotes: 0
Views: 93
Reputation: 6418
I assume you are using GREP Styles here.
Apply Bold to
(?<=PR-)(.+)
Apply Roman (i.e. neither bold nor italic) to:
,
(comma followed by a space)
and:
to
("to" preceded and followed by a space)
and:
, PR-
Apply Bold Italic to
(?<=-)(\d{2,3})(!\d)(!\.)
It should give you the result you want:
Upvotes: 2