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

how to replace space with en space after bold using grep?

New Here ,
Dec 25, 2018 Dec 25, 2018

Is there a way to replace space with en space after bold using grep in paragraph style?

marked in yellow is just a (space)

and this should be the output using (en pace)

1.9K
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 ,
Dec 26, 2018 Dec 26, 2018

Is the space directly after the bold text styled in bold or regular font weight?

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 ,
Dec 27, 2018 Dec 27, 2018

regular font

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 ,
Dec 27, 2018 Dec 27, 2018

What exactly does that mean? Regular font?

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 ,
Dec 27, 2018 Dec 27, 2018

Ah, if the font style for the space was also in bold, then the following would work as a single find/change command:

grep-bold.png

The font Times has both a “Bold” and “Regular” variant, where the find format uses Bold to only apply the GREP Find/Change to the space after the second word, but not in the Regular style/weight text.

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 ,
Dec 27, 2018 Dec 27, 2018

In my tests the space after the bold text remains bold, even if I try to explicitly set it as regular weight (not using styles)… Are you sure that the space is not in bold weight? EDIT: I think that I had a style override issue from testing GREP paragraph styles, as I can now specify the space in regular after clearing the style.

Can you provide a sample file? It is pointless testing and offering further suggestions on docs that do not match yours.

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 ,
Dec 26, 2018 Dec 26, 2018

You can't do EXACTLY what you're asking to do via a GREP style because GREP styles can only format the text that is there, not replace text with something else. You could do that with a GREP find/change but not with a GREP style.

That being said, you can pretty much do what you want with a slightly different approach. Create a character style and apply a horizontal scale value in that character style. Call it something like "stretch space" or whatever you like. Now, you can apply that character style to the space that follows the last bold character of the text with the "stretch space" effectively achieving the same result.

Now, how to isolate that space after the bold text 😉 That might get a little tricky. I'd need to see some actual examples of your content, but I'm thinking you might have better luck using a Nested Style vs. a GREP style.

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 ,
Dec 27, 2018 Dec 27, 2018

Chad Chelius  wrote

You could do that with a GREP find/change but not with a GREP style.

[…]

you might have better luck using a Nested Style vs. a GREP style.

I doubt Nested styles could help, because 'GREP styles can only format the text, not replace it with something else', as you said already. Nested styles have the same limitations. I'd use a Find/Change:

Find what: ^.+

Change to: $0@

Find Format:

Character style: bold (I'd recommend to use styles for any text formatting)

or just: + Bold (in case you don't use char style)

That said, we isolate first regular space after bolded text in the beginning of every paragraph, marking it with some special glyph (I used at sign here)

Now the 2nd Find/Change query:

Find what: @\s (at sign followed by a space)

Change to: ~> (en space)

Done.

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 ,
Dec 27, 2018 Dec 27, 2018

Not truly relevant because the last "bold" char could alas be … a space!

Best,

Michel, for FRIdNGE

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 ,
Dec 27, 2018 Dec 27, 2018

question in post 1, answer in post 3.

or you mean something different?

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 ,
Dec 27, 2018 Dec 27, 2018

All know the enrichments application is not really always well done! …

So, a bad point to be taken in account in a Grep code!

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
Mentor ,
Dec 27, 2018 Dec 27, 2018

Nothing is 'really always well done'. You always work with a given text. OP says a space after bold text is regular? OK, I play with this. Why I should take into account somewhat somewhere in some other texts may be not true? This regex isn't going to be carved in stone.

Is it still doable using F/C if format of that space varies? Sure, just a little bit trickier.

Should someone bother about it now? Nope.

It's a matter of view, after all. See no point to discuss this further.

Another thing, quite likely, totally different approach is possible, maybe even 'one-click'? Just share it, what the problem?

I'll be the first to 'like' it, promise

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 ,
Dec 28, 2018 Dec 28, 2018

FWIW, the second take.

Still based on assumption the space to be replaced has no Character style applied and/or has Regular weight. You’ll just need to adjust Find Format settings accordingly.

Simple as that:

(?<!\S)\x{20}

Nspace.gif

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 ,
Dec 28, 2018 Dec 28, 2018

… and how do you do if a the "bold" char style is applied to "event"?! …

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 ,
Dec 28, 2018 Dec 28, 2018
LATEST

And what if not? And what about your previous question about bolded 'last' space?

What if there is no other formatting at all except bold at the beginning of the paragraph, as it is shown in OP's sample?

I could continue endlessly myself, but, as Stephen_A_Marsh already said, it is pointless to guess at this stage.

Again, if you have in your hat a solution that covers all possible cases in one go, I'm all ears.

I know you're capable to do so much more than just ask silly questions.

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