0

Consider the following text:

This is a test text with b custom tags /b to apply a b bold /b character style.

In the above text, I have used b and /b as custom tags to designate a section I need to be in bold. I am trying to write a GREP expression into the paragraph style that will change the above text into the below, on the fly:

This is a test text with custom tags to apply a bold character style.

The regex I am using is:

( b .+? /b )

This works only partially. What it renders looks like this:

This is a test text with b custom tags /b to apply a b bold /b character style.

Can someone please help me correct the expression? How can I make the tags (b and /b) disappear?

  • 1
    You can’t. Regex is a searching/parsing technique; you cannot edit anything with regular expressions. You can do it with a regex replace (i.e., Edit → Find/Change → GREP tab), but that of course removes your custom tags from the story structure completely. If you edit your question to add why you need/have chosen to add those tags and what your workflow is, we can probably help you with alternative solutions that will work more efficiently. – Janus Bahs Jacquet Nov 24 '15 at 9:31
1

Create two character styles. One for Bold, one for invisible. in the invisible, go to advanced character formats, change text size to 1pt and horizontal scale to 1, this effectively makes the character so small it wont print or show.

now create a paragraph style, using GREP styles tab create a GREP to find the bold text, apply bold style. create a GREP to find the custom tags, apply invisible style

problem solved ;)

enter image description here

| improve this answer | |
  • Setting the text colour to none is also important; otherwise you may see a stray black dot. And while this works, it's hacky and the tags are still there as text, which is bad for accessibility and text extraction (if ever that will be needed). Depending on how many different documents we’re dealing with, where the tags come from, and what the desired textual output is, there may well be more suitable ways to do this. – Janus Bahs Jacquet Nov 24 '15 at 10:41
  • Ack. Looking at the output of the left, I see the text "bold" has been transmogrified to "old". Seems your GREPs need some tweaking. – usr2564301 Nov 24 '15 at 12:34
  • Frick! I knew i shouldve paid more attention to the GREP. it was only a 2 minute demo to show how it could work. – Benjamin Lake Nov 25 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.