1

I'm trying to automatize giving character styles to the editor given names (not the author names) in literature sources like this one via Find/Change (not GREP styles):

Jacobs, G. A., Boero, J. V., Quevillon, R. P., Todd-Bazemore, E., Elliott, T. L. & Reyes, G. (2002). Floods. In A. M. La Greca, W. K. Silverman, E. M. Vernberg & M. C. Roberts (Eds.), Helping children cope with disasters and terrorism (pp. 157 – 174). Washington, DC: American Psychological Association.

Doing that, I want to grap any capital letter followed by a dot AFTER the word In in a paragraph. Since the regular lookbehind (?<=) won't work with . and + opperators, I use \K

As an additional info to this particular case: Using a fine-tagging script, everything is already tagged with different character and paragraph styles, the script just has problems with the double/multiple given names of the editors which is why I'm trying to find them manually to correct them. I can't post the script here since it's not mine to give.

what I have:

  • I managed to grab all double or more names (singular is for a reason not necessary) which come after the word In:

    (In )\K([\u]\.( [\u]\.)+)

  • I managed to grab double or more names after the first occurence:

    (In [\u]\.( [\u]\.)* .+(\,|\&) )\K([\u]\.( [\u]\.)+)

I have multiple things not working out:

1. finding more than one occurence

The second query only finds the last occurence, not the ones inbetween. Since .+ looks for everything that comes before f.e. M. C., it seems to include any occurence that come before the last. I just can't seem to find a way to grab all occurences. Does anyone know a way or is this simply not possible

2. combining the search with "or" |

Both queries work for themself but I can't combine them with "or". Now in general it does work with simpler test queries but with the ones above. Possibly because the first query is a part of the second.

Does anyone have an idea how this could work?

Thanks in advance

4
  • 1
    Did you say in your comment that the initials of the authors before the In part (Jacobs, Boero, etc.) already have different styles applied? Or are they (at least potentially) completely unstyled? Feb 3, 2021 at 10:12
  • Yes, everything (or nearly everything) has already styles applied. I added that Info to the main post yesterday. (See paragraph before "What I have")
    – SabineR
    Feb 4, 2021 at 11:37
  • 1
    But that changes everything! Can’t you just search for (\u\.), then, and specify Character Style: [None]? If all the other authors are already styled (and perhaps titles as well?), that should only match the ‘in’ authors. You’ll probably get the odd false positive, but if you make the style you’re applying pink or something, you can check through it fairly easily to get rid of those. Feb 4, 2021 at 11:55
  • @JanusBahsJacquet, that sounds promising! (I need closure on this riddle 😅)
    – Wolff
    Feb 4, 2021 at 22:49

1 Answer 1

0

I can't say for sure that this isn't possible, but I haven't been able to find a way. Instead I can present kind of a workaround.

GREP styles are applied in sequence, so you can first style all capital letters followed by a dot and then afterwards remove the styling up to the word "In" like this.

The result looks like this:

Be aware that you can't just apply [None] to cancel the styling. You have to make another character style that actively reverts whatever styling you have applied.

7
  • 1
    Might be a good idea to make the To Text for the second one .+\. \<In\> or something along those lines, just to avoid it matching someone who has In in their name (say, Josh Ingram) or the word In appearing in the title (a title like ‘Allegory In The Prose Of H. G. Wells’ would wreck it). Jan 29, 2021 at 19:04
  • @JanusBahsJacquet, you are right. But your suggestion still wouldn't work if a title starts with "In" right? Can't really see how to avoid this ...
    – Wolff
    Jan 29, 2021 at 20:20
  • No, if a title (or subtitle, after a full stop) starts with In, there’d be no way to avoid it, you’d have to fix that manually. Jan 29, 2021 at 20:22
  • One could do a manual find/change searching for "In" and insert some character like End Nested Style Here before and then use that in the GREP style. Would require that you examine each instance, but still faster than manually applying the character style.
    – Wolff
    Jan 29, 2021 at 21:49
  • Thank you but apart from that I can't seem to get this to work with the occurences before "In", this work around is not an option for me. Because 1. the other parts also have different character styles for authors and titles and sources etc. And 2. this doesn't apply real character styles as in: when you mark the word, in the character style window the style is not selected. We need this for XML reasons. I really only want to find the occurences to correct what our fine tagging script for literature missed.
    – SabineR
    Feb 1, 2021 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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