try it on greep
Change: $1 - $2 = $3
1 person found this helpful
I do it in two steps, first changing the hyphens to en-dashes:
Find (?<=\d)-(?=\d) which finds any hypen between two digits
Replace ~= which is the en-dash
Then use a class to hold the math symbols:
Find (\d|\))([\+\*/~==])(\d|\() (this adds open and close parentheses to the search before or after a symbol -- if your equations don't use parentheses you can eliminate the |\( and |\) from the first and last search groups)
Replace $1 $2 $3 (there's a space between the terms there).
This does not include radicals, or advanced math symbols in the search, so if your equations use those, you need to add them, and it doesn't put spaces between digits and parentheses.
Forgot to mention that the first query that changes the hypens to en-dashes will change them everywhere they appear between two digits, so you run the risk of changing things besides your equatuions, like some date or phone number formats, unless you restrict the search scope.
Also, there is no provision for negative numbers in any of what I posted.
Thanks, that was great! I actually changed it a drop to accomplish two things in one, I changed the replace with $1 ~= $2 = $3, so it changed the dash to an en dash, and added the spaces at the same time.
so what are you doing for 3+4=7 or 9*5=45?
I'm doing this for each chapter individually, and each chapter only uses one math symbol. You're right, if they would all be in one document I would have a problem. I guess your reply addressed that issue, but it just looked so complicated , and I don't know grep very well so for now I'm doing it chapter by chapter.
Looks more complex that it is, really. You can just copy the query out of the forum and paste it into the dialog, and Jongware did a wonderful "what the grep" script http://forums.adobe.com/message/2698510