Copy link to clipboard
Copied
I'm a recent GREP crusader and after a few weeks or working with it, some of it is sinking in and starting to make sense. I'm creating a master template with paragraph styles and one of the many things I'm using GREP for is ensuring telephone numbers don't break over lines. I thought I had solved it but
(\d+ \d+)+
isn't cutting the mustard.
My telephone numbers will never be separated by punctuation but would need to account for several european/regional formats. Example formats could be; 0 00 00 000..., 0000 000 000, 00000 000000, etc. The telephone numbers could appear in the middle of paragraphs too.
I've tried quite a few variations now and I'm not sure where to go - any help would be appreciated!
EDIT: Well I feel stupid now but I thought this might help someone else. I fixed it with;
(\d+? \d+?)+
\d[\d\h]+\d
Copy link to clipboard
Copied
\d[\d\h]+\d
Copy link to clipboard
Copied
Thanks. I'm curious as to what your expression is better than my edit?
Copy link to clipboard
Copied
Didn't you notice that your regex doesn’t work (expectedly) on your own - second - sample?
Michel's one is much more flexible and universal, and still safe.
Copy link to clipboard
Copied
Nope, but I have now! Thanks to both replies.
Copy link to clipboard
Copied
Not exactly! … This kind of code will work … [even if I don't like it!]
But it's just a personal comment.
Best,
Michel
Find more inspiration, events, and resources on the new Adobe Community
Explore Now