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

Find 4 first words of a sentence

Return to Member Forum

  • Author
    Posts
    • #75287

      Hi,

      i’m working on a manual for a french schoolbook.
      In that manual all the exercises from that schoolbook need to be repeated, but only the 4 first words, followed by ‘…’
      Here’s an example:
      1 This is the first exercise from the schoolbook.
      2 And yes this is off cours the second one.
      Needs to become:
      1 This is the first …
      2 And yes this is …

      All the exercises are styled with the paragraph style ‘exercise’ and are always ‘digit-tab-text.’
      So this is what i use in the F&Ch window:
      Find what: (^\d)((\<\w+\> ){4}).+
      Change to: $1$2…

      This grep works fine until one of the first 4 words contain a quotation mark.
      For example: ‘1 I’m asking a question here.’ is not changed with this grep.

      How can i solve that issue?

      kind regards

    • #75299
      Aaron Troia
      Participant

      I used pretty much the same GREP you provided with a simple tweak, try :

      Find: (^\d)((\<[A-Za-z']+\> ){4}).+
      Replace: $1$2…

      and if you find any other characters (comma’s, periods, semi-colons, etc.), just put them between the square brackets and it will find them too. Let me know if that works for you.

    • #75317

      Hi, this works fine for me !!!
      Thx for the quick reply.

    • #75389
      Masood Ahmad
      Participant

      @Ron, I tried putting the punctuation marks inside the square brackets but it didn’t worked. Therefore, I tweaked the code to include all of them:

      Find: (^\d)((\<[A-Za-z]+\>[.,?!;:'"]* ){4}).+

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