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

Replacing Variable Query

Explorer ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Is there a simple way (without scripts) to add in a hypen to a variable query?

 

For example, If I have an address say:
221B Baker Street
I want to be able to place a hyphen to instead make it: 
221-B Baker Street

 

But my other variable is a Suite number such as: 

1107 Brooklyn Boulevard, Suite A350
but this should also be hyphenated to: 

1107 Brooklyn Boulevard, Suite A-350

 

Here is my Find What:

(\u\d)|(\d\u)

But I want to be able to change to: 

$1-$2

But this doesn't work because of the variability. Any help?

TOPICS
How to

Views

346

Translate

Translate

Report

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 , Feb 11, 2021 Feb 11, 2021

\u\K\d|\d\K\u

-$0

 

(^/)  The Jedi

Votes

Translate

Translate
Community Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

The following substitution i.e. "change to" term should work

$1$3-$2$4

See the demo here  

However, when trying in InDesign it is placing $3 and $4 literally while substitution. In order to force it to recognize $3 and $4 we need to have some other character between $1 and $3 and likewise between $2 and $4. I used a hairline space, you could try with some other whitespace character. The following works for me

Find What

(\d)(\u)|(\u)(\d)

Change To

$1~|$3-$2~|$4

-Manan

Votes

Translate

Translate

Report

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
Explorer ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

Is there no way to do this without the hairline space? My team does a lot of find/replaces, and I'd hate for their query to miss something because of a space added in

Votes

Translate

Translate

Report

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 ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

Using a single query I could not find any other way to make it work. As I showed in the demo, it works with other flavors of Regex implementation but InDesign's implementation does not work. I would await some grep geniuses on the forum to dish out a gem for this. For me, if the proposed solution does not fit the bill then it has to be done by using two separate queries.

-Manan

Votes

Translate

Translate

Report

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
Explorer ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

Thank you for your help. I will see if anyone else has an answer. Thanks!

Votes

Translate

Translate

Report

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 ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

\u\K\d|\d\K\u

-$0

 

(^/)  The Jedi

Votes

Translate

Translate

Report

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
Explorer ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

Omg, this is exactly what I needed! I had no idea what /K was, but I might have to start usisng it more!!

Votes

Translate

Translate

Report

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 ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

LATEST

Ahh, brilliant. I did think of using \K but the piece that I was missing is $0

-Manan

Votes

Translate

Translate

Report

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