4 Replies Latest reply on Mar 8, 2015 10:04 AM by akiva_atwood

    Transpose two hebrew words with nikud

    akiva_atwood

      Hi

       

      I have a hebrew paragraph with two words that need to be transposed:

       

      aaaaa {bbbbb} ccccc    ->  aaaaa ccccc {bbbbb}

       

      WIthout diacritics/nikud a simple grep in a script works fine:

       

      (\w+)( )(\{)(\w+)(\})    ->   $3$4$5 $1

       

      HOWEVER

       

      If there is nikud in the hebrew \w+ doesn't detect the words...

       

      I've tried using \X+ instead of \w+ but that doesn't always detect the closing } and continues until the NEXT occurance

       

      IS there a way to do this in a script?

       

      Thanks

        • 1. Re: Transpose two hebrew words with nikud
          Trevorׅ Adobe Community Professional

          Hi Akiva,

           

          Easy if you use the Unicode range.

          Find: ([\x{0590}-\x{05ff}]+) \{([\x{0590}-\x{05ff}]+)\} ([\x{0590}-\x{05ff}]+)

          Replace: $1 $3 {$2}

           

          Trevor

          • 2. Re: Transpose two hebrew words with nikud
            akiva_atwood Level 1

            Hi Trevor

             

            Thanks -- that works great from the grep dialog -- but not in my code:

             

                app.findGrepPreferences = NothingEnum.NOTHING;

                   app.changeGrepPreferences = NothingEnum.NOTHING;

                   app.findGrepPreferences.findWhat="([\x{0590}-\x{05ff}]+)( )(\{)([\x{0590}-\x{05ff}]+)(\})";

                   app.changeGrepPreferences.changeTo="$3$4$5 $1";

                  x=doc.changeGrep();

                   alert(x.length+" changed");

                   app.findGrepPreferences.findWhat="(\{)([\x{0590}-\x{05ff}]+)(\})";

                   app.changeGrepPreferences.changeTo="\[$2\]";

                   app.changeGrepPreferences.appliedCharacterStyle = myDoc.characterStyles.itemByName("ChumashKiri");

                 x=doc.changeGrep();

                   alert(x.length+" changed");

             

            Any idea why not?

            • 3. Re: Transpose two hebrew words with nikud
              Trevorׅ Adobe Community Professional

              You need to escape the escapes when you put it in code

              var doc = app.activeDocument;
              app.findGrepPreferences = NothingEnum.NOTHING;
              app.changeGrepPreferences = NothingEnum.NOTHING;
              app.findGrepPreferences.findWhat="([\\x{0590}-\\x{0600}]+) \\{([\\x{0590}-\\x{0600}]+)\\} ([\\x{0590}-\\x{0600}]+)";
              app.changeGrepPreferences.changeTo="$1 $3 {$2}";
              var x=doc.changeGrep();
              alert(x.length+" changed");
              

               

              Use the same principle for the second grep. (I left it for you to practice )

              I don't know why you are bracketing the space and curly brackets instead of just using the simple replacement as I do.

               

              Regards

               

              Trevor

              • 4. Re: Transpose two hebrew words with nikud
                akiva_atwood Level 1

                Thanks -- I always forget to escape the escape

                 

                Re brackets: Habit. I start off verbose (which is why everything is bracketed) -- then combine once it's working

                 

                Thanks