Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

En space between abbreviations with GREP!?

Return to Member Forum

  • Author
    Posts
    • #57383
      jpannier
      Member

      I’m quite new to GREP. (This is an excuse in case this question is too simple ;-) But I don’t get it.

      I want to create a find/change query to replace a regular space with an En space within an abbreviation for example: e._g. or J._K. Rowling

      Finding a space followed by any word character followed by a period is not the problem. The big issue – for me – is to exclude the case of a word followed by a period at the end of a sentence. For example: … good point. E. g. blabla

      (Maybe this example looks strange, but I’m German and we could start a sentence with an abbreviation – and we do ;-)

      If somebody knows the answer or a workaround I would be happy. If this is a problem that GREP couldn’t solve – this would be an answer too.

      Thanks

      Jeldrik

    • #57384

      So far you seem to be doing alright :) Except — an en-space? Isn't that far too wide? Perhaps you meant a Thin Space? (If so, use ~< below where I now have ~>)

      It's fairly easy — you don't really want this:

      w. w..

      because the first w may be the last character of a longer word. So all you have to do is insert a word break b before that first w!

      b[ul]. [ul].

      (I'd rather suggest using [ul] instead of w, because the 'word character' set also includes digits.)

      With all parentheses in place, this would be your Find

      b([ul].) ([ul].)

      and this your Replace

      $1~>$2

      (Advanced:

      It's also possible to use Lookbehind/Lookahead, like this:

      (?<=b[ul].) (?=[ul].)

      and then you'd only have to use this in Replace:

      ~>

      I think the Lookbehind/Lookahead approach would be slightly faster, because ID only has to 'touch' the space itself (although the actual difference would be very minor).)

    • #57385
      jpannier
      Member

      Hi,

      thanks for this respose. In my first tries I was dealing with Lookbehind/Lookahead and with [ul]. but the clou are your boundaries. Perfect. And you're right with the ~< – in the German version we would call it “Achtelgeviert” ;-).

    • #57399

      Good!

      (A tip, specific for this forum: as you might have seen on re-reading your own post, the forum editor can't mentally cope with single backslashes. To make them visible, you have to insert them twice: \u and . Guess how many I had to insert here.

      It's the main cause of many a frantic post-edit. An additional “ouch” is that if you forgot just one and edit your post to correct this, all of the double backslashes were already translated to a single one, and you have to hunt for all of them again!

      … As you can see, I didn't need to edit my post ;))

    • #57403
      jpannier
      Member

      Thanks again.

      I thought I screwed up. But it wasn't me – it was the editor ;-).

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Forum Ads