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

Using grep style to add a 3 digit number in front of any 6 digit number

New Here ,
Aug 22, 2017 Aug 22, 2017

Im looking to be able to add a 3 digit number in front of any 6 digit number that i find for example 380005 becomes 12538005 and 690567 becomes 125690567 and so on.

I have this as the find

(\d\d\d\d\d\d)

But am struggling to find a style that will say place 125 or whatever the 3 digit code is in front of the 6 that i have.

Any help appreciated

1.3K
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
LEGEND ,
Aug 22, 2017 Aug 22, 2017

You can't with a Grep style!

Try a F/R:

Find: \b\d{6}\b

Replace by: 125$0

(^/)

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
New Here ,
Aug 22, 2017 Aug 22, 2017

Just got the answer to this and apparently you can. I think this is basically doing the same thing that you have outlined the $1 refers to the bracketed six digits

(\d\d\d\d\d\d)

125$1

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
LEGEND ,
Aug 22, 2017 Aug 22, 2017

Not exactly the same! 

try with: 0123456789

… and the parenthesis aren't not useful if not other group(s)!

Think simple and global! (even if you don't need it!)

(^/)

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 Expert ,
Aug 22, 2017 Aug 22, 2017

Backbone22  wrote

Just got the answer to this and apparently you can.

No you cannot. A GREP style can only apply formatting to a text, found with a GREP. See the online help: Drop caps and nested styles in InDesign

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
Enthusiast ,
Aug 22, 2017 Aug 22, 2017

You say GREP style, which is why the answers above say you can't do it. You can't do this as a GREP style within a paragraph style. Or did you just generally mean a GREP expression?

To clarify, you can only (as Jongware stated) apply formatting via a character style to text found with GREP style in a paragraph style. If you need to add, subtract, re-arrange, or otherwise modify the found text, then you need to use the Find/Change dialog box...which is where you would need to work for your needs here.

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
New Here ,
Aug 22, 2017 Aug 22, 2017
LATEST

I guess i meant Grep expression as i used the Grep function in the Find/Change dialog box which worked for me.

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