10 Replies Latest reply on Aug 18, 2013 10:09 PM by MakeFast

    New! script to  Find address

    MakeFast

      Hi Forum,,

       

      I'm very interested to join this forum..

       

      Actually my need is to find the telephone numbers from address and to change to below format.

       

      eg.

      LONDON;

      handle  street,

      123 post,

      +90 90 09 09

       

      and it must be changed to the format;

      eg.

      LONDON;

      handle  street,

      123 post,

      +90, 900, 909

       

       

      I have this but it search only the first 3 line and not change the telephone numbers;

      thanks forum..

        • 1. Re: New! script to  Find address
          Sajeev Sridharan Level 4

          this you can achieve using grep itself:

           

          find: (\+\d+) (\d)(\d) (\d)(\d) (\d)(\d)

          change: $1, $2$3$4, $5$6$7

           

          Hope this will help you.

           

          Vandy

          • 2. Re: New! script to  Find address
            csm_phil Level 4

            Hi MakeFast,

             

            Try the below line in the Grep (find and change).

             

            FIND: (?<=\+)(\d{2}) (\d{2}) ([0-9])([0-9]) (\d{2})$

             

            CHANGE: $1, $2$3, $4$5

             

            thx,

            csm_phil

            • 3. Re: New! script to  Find address
              MakeFast Level 1

              HI vandy and csm_phil,

               

              again many thanks and one more request,

               

              I just want to find the numbers, with space and without space (I can't assume if the telephone numbers have 2digits and space 2 digits and space.)

               

              may be without space or may be 2 spaces between digits or now spaces continusouly digits.. +90900909 or +90    90   0909 like this...

               

              So, can we have chance to find London and below contents and if the last line is digit, it should be ...+90, 900, 909...

               

              Many thanks vandy and csm_phil

              • 4. Re: New! script to  Find address
                Sajeev Sridharan Level 4

                `try "OR" function in Grep, like below

                 

                find:  (\+\d)(\d)\s(\d)(\d)\s(\d)(\d)\s(\d)(\d)|(\+\d)(\d)\s\s(\d)(\d)\s\s(\d)(\d)\s\s(\d)(\d)

                change: $1$2, $3$4$5, $6$7$8

                 

                Use pipe symbol, which denotes OR function

                 

                Vandy

                • 5. Re: New! script to  Find address
                  MakeFast Level 1

                  HI vandy 88,

                   

                  is it possible to check like this...

                   

                  i.e. find using +971 code and give spacing

                   

                  i.e. if it is like this +971090909

                   

                  to be like this

                   

                  +971 09 09 09

                   

                  tf = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements;

                  for(i=0; i<tf.length; i++) {

                  if(tf[i].contents == "+971" + "[//d+//s]") {            //assuming any digits with space or without space after +971

                      app.changeGrepPreferences.changeTo = "+ 971 22 22 22";

                      app.changeGrep();

                      }}

                   

                  Many thanks

                  • 6. Re: New! script to  Find address
                    MakeFast Level 1

                    Im so tired in find like this...... help me forum... shhhhh mmmm ahhh ahhh pain in my fingers...

                    ^(\+971)+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])

                    ^(\+971) +([\d])+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])

                    ^(\+971) +([\d]) +([\d])+([\d])+([\d])+([\d])+([\d])+([\d])+([\d])

                    ^(\+971) +([\d])+([\d]) +([\d])+([\d]) +([\d])+([\d]) +([\d])+([\d])

                     

                    I want to find digits after +971...

                    things is , it can be any digit and with any type of spacing like this....

                    +971989080223

                    +972989080223

                    +971989080 223

                    +971 9 89080243

                    +971 9 8 9080243

                    +971 9 8 9 080243

                    +971 232 3 23 23

                    +971 2323 2323

                     

                    all i need to do is.... retain digits but with below mentioned format

                    +971 98 90 80 22

                    +971 23 23 23 23

                     

                    pllllllllllllllllllllese help....

                     

                    can this be done in short and easy method.....

                    • 7. Re: New! script to  Find address
                      ecr1inf

                      Do you need a script? I would search for +971 followed by a space and replace with +971 only, then search for 971(\d) followed by a space and replace with +971$1, running this search until it fails.

                       

                      Then search for +971(\d\d)(\d\d)(\d\d)(\d\d) and replace with +971 $1 $2 $3 $4

                       

                      I'm assuming you have a paragraph at the end of each line.

                       

                      There could well be better ways.

                       

                      A.

                      • 8. Re: New! script to  Find address
                        Jump_Over Level 5

                        Hi,

                         

                        All posts showed you a good ways.

                        These ways should lead you to a script code or to UI "find...change" dialog.

                        As you wrote you are interested to join this forum

                        here is a "welcome gift" from me:

                         

                        var mDoc = app.activeDocument,
                        // 1/2 em space (modify this if need)
                        bigSpace = "~>",
                        // 1/4 em space (modify this if need)
                        smallSpace = "~4" ;
                        app.findGrepPreferences = app.changeGrepPreferences = null;
                        // match "971" at the beginning of para - with spaces or without - with "+" or without
                        // and eigth digits with spaces or without
                        app.findGrepPreferences.findWhat = 
                                  "^\\s*\\+*\\s*9\\s*7\\s*1" +
                                  "\\s*(\\d)\\s*(\\d)\\s*(\\d)\\s*(\\d)"+
                                  "\\s*(\\d)\\s*(\\d)\\s*(\\d)\\s*(\\d)";
                        //change to "+971" and paired digits with chosen kind of spaces
                        app.changeGrepPreferences.changeTo = 
                                  "+971"+bigSpace+
                                  "$1$2"+smallSpace+"$3$4"+smallSpace+"$5$6"+smallSpace+"$7$8";
                        //do the job
                        mDoc.changeGrep();
                        //clear find & change Grep prefs
                        app.findGrepPreferences = app.changeGrepPreferences = null;
                        

                         

                        enjoy:)

                         

                        Jarek

                        • 9. Re: New! script to  Find address
                          MakeFast Level 1

                          Dear Jarek!!!!

                           

                          Thanks for your help.. THis is what i need...

                           

                          Actually I tried with the clues from others, but they use to find only, if matches...

                           

                          In yours, the seperator *  helped all the way to differentiate (/d)(/s)* between (/d)(/s)*.....

                           

                          I also tried with this my own....

                          (\+971)[-. ]?(\d{2})[-.]?(\d{2})[-.]?(\d{2})[-.]?(\d{3})[-.]?(\d{1})

                          but this resembles like others clues, which find only if matches...

                           

                          SO yours is the best one out of all.......

                           

                          thank you Genius.....J

                          • 10. Re: New! script to  Find address
                            MakeFast Level 1

                            Thank you Jarek!!!!

                             

                            Thanks a ton...