Regex to insert EN space

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3















Indesign CS5.



I'm trying to perfect a regular expression to quickly replace the single-space from raw text to the EN space. I'm using the following:



(w)([.!?])(['"]0,1) 1,(['"]0,1)(u)


Replacing to:



$1$2$3~>$4$5


This should have captured and replaced the space with an EN space the following tests:



work. To
work! To
work." To
work.' 'To
work." "To


etc. I recognize it's not perfect as work.' "To would get through it, but that would be picked up in the editing sweeps. Please ignore that and similar conditions.



My problem is the replacement is coming out as...



work. $5o


The RegEx is finding text perfectly. If it finds work." "To, it replaces the space with an EN-space perfectly. Anything else isn't replacing correctly.



It appears that the (['"]0,1) expressions, since they're capturing nothing, are not having their relevant $# (e.g., $3) variable set. However, if that's the case, I expected to see work. $4$5o as the replacement for the work. To test.



Is there a workaround for this, or am I condemned to running a series of RegEx replacements?










share|improve this question


























    3















    Indesign CS5.



    I'm trying to perfect a regular expression to quickly replace the single-space from raw text to the EN space. I'm using the following:



    (w)([.!?])(['"]0,1) 1,(['"]0,1)(u)


    Replacing to:



    $1$2$3~>$4$5


    This should have captured and replaced the space with an EN space the following tests:



    work. To
    work! To
    work." To
    work.' 'To
    work." "To


    etc. I recognize it's not perfect as work.' "To would get through it, but that would be picked up in the editing sweeps. Please ignore that and similar conditions.



    My problem is the replacement is coming out as...



    work. $5o


    The RegEx is finding text perfectly. If it finds work." "To, it replaces the space with an EN-space perfectly. Anything else isn't replacing correctly.



    It appears that the (['"]0,1) expressions, since they're capturing nothing, are not having their relevant $# (e.g., $3) variable set. However, if that's the case, I expected to see work. $4$5o as the replacement for the work. To test.



    Is there a workaround for this, or am I condemned to running a series of RegEx replacements?










    share|improve this question
























      3












      3








      3








      Indesign CS5.



      I'm trying to perfect a regular expression to quickly replace the single-space from raw text to the EN space. I'm using the following:



      (w)([.!?])(['"]0,1) 1,(['"]0,1)(u)


      Replacing to:



      $1$2$3~>$4$5


      This should have captured and replaced the space with an EN space the following tests:



      work. To
      work! To
      work." To
      work.' 'To
      work." "To


      etc. I recognize it's not perfect as work.' "To would get through it, but that would be picked up in the editing sweeps. Please ignore that and similar conditions.



      My problem is the replacement is coming out as...



      work. $5o


      The RegEx is finding text perfectly. If it finds work." "To, it replaces the space with an EN-space perfectly. Anything else isn't replacing correctly.



      It appears that the (['"]0,1) expressions, since they're capturing nothing, are not having their relevant $# (e.g., $3) variable set. However, if that's the case, I expected to see work. $4$5o as the replacement for the work. To test.



      Is there a workaround for this, or am I condemned to running a series of RegEx replacements?










      share|improve this question














      Indesign CS5.



      I'm trying to perfect a regular expression to quickly replace the single-space from raw text to the EN space. I'm using the following:



      (w)([.!?])(['"]0,1) 1,(['"]0,1)(u)


      Replacing to:



      $1$2$3~>$4$5


      This should have captured and replaced the space with an EN space the following tests:



      work. To
      work! To
      work." To
      work.' 'To
      work." "To


      etc. I recognize it's not perfect as work.' "To would get through it, but that would be picked up in the editing sweeps. Please ignore that and similar conditions.



      My problem is the replacement is coming out as...



      work. $5o


      The RegEx is finding text perfectly. If it finds work." "To, it replaces the space with an EN-space perfectly. Anything else isn't replacing correctly.



      It appears that the (['"]0,1) expressions, since they're capturing nothing, are not having their relevant $# (e.g., $3) variable set. However, if that's the case, I expected to see work. $4$5o as the replacement for the work. To test.



      Is there a workaround for this, or am I condemned to running a series of RegEx replacements?







      adobe-indesign regex






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 25 at 18:41









      JBHJBH

      1377




      1377




















          1 Answer
          1






          active

          oldest

          votes


















          4














          If you need to change a regular space s for an EN space I think is more simple:



          (?<=.|!|"|')s(?=.|"|')


          search al the regular spaces s preceded by a dot . , !, " or ' and behind a character ., " or '



          and change it for an EN space



          ~>


          enter image description here




          Actually the second part is redundant, because " and ' are also characters, it must be:



          (?<=.|!|"|')s(?=.)


          If the rule is the s behind a letter or " or ' :



          (?<=.|!|"|')s(?=u|l|"|')


          If the letter is always an uppercase :



          (?<=.|!|"|')s(?=u|"|')


          enter image description here






          share|improve this answer

























          • This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

            – JBH
            Jan 25 at 19:06











          • Answer updated.

            – Danielillo
            Jan 25 at 19:11











          • I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

            – JBH
            Jan 25 at 19:14











          • Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

            – JBH
            Jan 25 at 19:16






          • 1





            We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

            – JBH
            Jan 25 at 19:28











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "174"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgraphicdesign.stackexchange.com%2fquestions%2f119598%2fregex-to-insert-en-space%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          If you need to change a regular space s for an EN space I think is more simple:



          (?<=.|!|"|')s(?=.|"|')


          search al the regular spaces s preceded by a dot . , !, " or ' and behind a character ., " or '



          and change it for an EN space



          ~>


          enter image description here




          Actually the second part is redundant, because " and ' are also characters, it must be:



          (?<=.|!|"|')s(?=.)


          If the rule is the s behind a letter or " or ' :



          (?<=.|!|"|')s(?=u|l|"|')


          If the letter is always an uppercase :



          (?<=.|!|"|')s(?=u|"|')


          enter image description here






          share|improve this answer

























          • This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

            – JBH
            Jan 25 at 19:06











          • Answer updated.

            – Danielillo
            Jan 25 at 19:11











          • I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

            – JBH
            Jan 25 at 19:14











          • Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

            – JBH
            Jan 25 at 19:16






          • 1





            We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

            – JBH
            Jan 25 at 19:28
















          4














          If you need to change a regular space s for an EN space I think is more simple:



          (?<=.|!|"|')s(?=.|"|')


          search al the regular spaces s preceded by a dot . , !, " or ' and behind a character ., " or '



          and change it for an EN space



          ~>


          enter image description here




          Actually the second part is redundant, because " and ' are also characters, it must be:



          (?<=.|!|"|')s(?=.)


          If the rule is the s behind a letter or " or ' :



          (?<=.|!|"|')s(?=u|l|"|')


          If the letter is always an uppercase :



          (?<=.|!|"|')s(?=u|"|')


          enter image description here






          share|improve this answer

























          • This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

            – JBH
            Jan 25 at 19:06











          • Answer updated.

            – Danielillo
            Jan 25 at 19:11











          • I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

            – JBH
            Jan 25 at 19:14











          • Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

            – JBH
            Jan 25 at 19:16






          • 1





            We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

            – JBH
            Jan 25 at 19:28














          4












          4








          4







          If you need to change a regular space s for an EN space I think is more simple:



          (?<=.|!|"|')s(?=.|"|')


          search al the regular spaces s preceded by a dot . , !, " or ' and behind a character ., " or '



          and change it for an EN space



          ~>


          enter image description here




          Actually the second part is redundant, because " and ' are also characters, it must be:



          (?<=.|!|"|')s(?=.)


          If the rule is the s behind a letter or " or ' :



          (?<=.|!|"|')s(?=u|l|"|')


          If the letter is always an uppercase :



          (?<=.|!|"|')s(?=u|"|')


          enter image description here






          share|improve this answer















          If you need to change a regular space s for an EN space I think is more simple:



          (?<=.|!|"|')s(?=.|"|')


          search al the regular spaces s preceded by a dot . , !, " or ' and behind a character ., " or '



          and change it for an EN space



          ~>


          enter image description here




          Actually the second part is redundant, because " and ' are also characters, it must be:



          (?<=.|!|"|')s(?=.)


          If the rule is the s behind a letter or " or ' :



          (?<=.|!|"|')s(?=u|l|"|')


          If the letter is always an uppercase :



          (?<=.|!|"|')s(?=u|"|')


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 25 at 19:25

























          answered Jan 25 at 19:01









          DanielilloDanielillo

          22.3k13277




          22.3k13277












          • This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

            – JBH
            Jan 25 at 19:06











          • Answer updated.

            – Danielillo
            Jan 25 at 19:11











          • I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

            – JBH
            Jan 25 at 19:14











          • Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

            – JBH
            Jan 25 at 19:16






          • 1





            We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

            – JBH
            Jan 25 at 19:28


















          • This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

            – JBH
            Jan 25 at 19:06











          • Answer updated.

            – Danielillo
            Jan 25 at 19:11











          • I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

            – JBH
            Jan 25 at 19:14











          • Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

            – JBH
            Jan 25 at 19:16






          • 1





            We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

            – JBH
            Jan 25 at 19:28

















          This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

          – JBH
          Jan 25 at 19:06





          This looks promising, I'll be back after I've tested it. Note that you can't use the whitespace character (s) because it matches the end-of-paragraph, so s1, will collapse paragraphs. that's why I'm using a simple space (which, in my case, is predictable).

          – JBH
          Jan 25 at 19:06













          Answer updated.

          – Danielillo
          Jan 25 at 19:11





          Answer updated.

          – Danielillo
          Jan 25 at 19:11













          I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

          – JBH
          Jan 25 at 19:14





          I'm using (?<=.|!|"|') 1,(?=u|l|"|'), but it's matching work" to, which it cannot do. I'll try your last RegEx in your current answer.

          – JBH
          Jan 25 at 19:14













          Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

          – JBH
          Jan 25 at 19:16





          Nope. (?<=.|!|"|')s(?=u|"|') matches end-of-paragraph and collapses paragraphs. (?<=.|!|"|') 1,(?=u|"|') fixes that problem, but it's still matching work" to, which it cannot do. The [.?!] preceding the space between sentences is mandatory.

          – JBH
          Jan 25 at 19:16




          1




          1





          We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

          – JBH
          Jan 25 at 19:28






          We have a winner! You must replace s with 1, (there's a single space preceding that left brace) or end-of-paragraph markers are captured and the paragraphs collapsed, but I sincerely appreciate your help working around InDesign's weakness! Thanks!

          – JBH
          Jan 25 at 19:28


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Graphic Design Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgraphicdesign.stackexchange.com%2fquestions%2f119598%2fregex-to-insert-en-space%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay