Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

GREP to keep telephone number from breaking

Community Beginner ,
Jun 29, 2018 Jun 29, 2018

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+?)+

927
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jun 29, 2018 Jun 29, 2018

\d[\d\h]+\d

Translate
Guide ,
Jun 29, 2018 Jun 29, 2018

\d[\d\h]+\d

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2018 Jun 29, 2018

Thanks. I'm curious as to what your expression is better than my edit?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 29, 2018 Jun 29, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 29, 2018 Jun 29, 2018

Nope, but I have now! Thanks to both replies.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 29, 2018 Jun 29, 2018
LATEST

Not exactly! … This kind of code will work … [even if I don't like it!]

But it's just a personal comment.

Best,

Michel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines