a little help with GREP?
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / a little help with GREP?
- This topic has 9 replies, 2 voices, and was last updated 9 years, 4 months ago by Oleh Melnyk.
-
AuthorPosts
-
-
October 23, 2014 at 2:25 pm #71213tomas kuceryMember
hello, im working on a law paper and have some problems with numbers.. to be more specific:
what i have:
“you can find something in § 15, 25, 26, 27, 28, 29, 55..”
what i want to have:
“you can find something in § 15, 25-29, 55..”
or
“we discussed this problem on pages 15, 16, 17”
what i want to have:
“we discussed this problem on pages 15-17” (or 15 to 17, doesnt really matter)of course, the numbers are different every time, the point is i need to find a set of numbers in range and change them to a simple separator..
is anything like this even possible by using GREP? or a script?
many thanks!
-
October 26, 2014 at 7:14 am #71250Oleh MelnykMember
Hi,
I’m not a great scripter, but here is my solution https://www.dropbox.com/s/f6ctvw1kl5povi9/Detect%20digit%20range.jsx?dl=0
Script code is pretty dirty and requires a strong refactoring, but seems it works just as it should – check and let me know how it goes…
If somebody have any suggestions of how to improve this script – feel free to contact me!
-
November 4, 2014 at 3:18 am #71421tomas kuceryMember
hello there,
sorry for the late response..
your script works great! it finds all the numbers i want and changes it to what i need, but..
..it changes numbers i dont want to be changed, f.e. 5,6 changes to 5-6 (i only need to put the separator between three numbers in range, not two..)
is it fixable? can you change the script this way? (i tried and failed miserably :)
anyway, good job, thank you for it and if my problem with two numbers in range doesnt have the solution, i can handle it ;)
thanks again and be well!
-
November 4, 2014 at 2:02 pm #71431Oleh MelnykMember
I spent whole day, trying to figure out how to make this work and how to refactor the code.. I thought that my brain will blow up.. but I finally made it, and now I get satisfaction from this)))
check updated version and let me know if it works for you https://www.dropbox.com/s/llzn9d6iq8ikiyo/Detect%20digit%20range%202.jsx?dl=0
-
November 5, 2014 at 3:43 pm #71453tomas kuceryMember
you, sir, you deserve a medal! works perfectly and thanks for the alert, i promise i will never run the script twice :D
you didnt have to spend so much time with it but Im very glad you did :)
i looked at the script you made and its so complicated my brain almost blew up as well, incredible!
once again, thanks a lot!
i wish i had something to offer to help you with (im afraid i dont but you can try ;)
take care!
-
November 5, 2014 at 4:37 pm #71455Oleh MelnykMember
haha)) I just added another “if” to check if ranges are already set, so script will not screw up now after multiple execution.. you may remove alert if they bother you)))
upd: https://www.dropbox.com/s/llzn9d6iq8ikiyo/Detect%20digit%20range%202.jsx?dl=0
-
November 11, 2014 at 2:36 am #71557tomas kuceryMember
the alerts are fine, at least i know i used the script correctly :)
have a one tasty beer on me, good man! :)
take care
-
November 11, 2014 at 5:32 am #71558Oleh MelnykMember
actually I have discovered a serious bug in previous version: if there is more than one string with ranges – script replace second and all other digit-strings with first formatted result, which is not good.. so I made another update:
https://www.dropbox.com/s/f6ctvw1kl5povi9/Detect%20digit%20range.jsx?dl=0
in this version:
– script work correctly with more than one digit-string per document
– it can now work with selection only, if nothing selected – it will process whole document
– it use progress bar instead of alerts
… and other small fixes -
November 13, 2014 at 9:16 am #71618tomas kuceryMember
you really want to get the medal, dont you? :)
to be honest i tried the script only on a small piece of work and it worked good, i havent finished the whole job yet..
but thank you again for taking care of the script, i believe this time its absolutely perfect (unless you find other bug in it :)
thanks and be well! -
November 13, 2014 at 9:23 am #71619Oleh MelnykMember
no, I don’t need medals, lol
I just have found this script useful, and I want to include it to my other script, that will be more complex and do multiple [clever] find/change fixes, that’s why I’m searching for bugs and keep fixing them
-
-
AuthorPosts
- You must be logged in to reply to this topic.