Copy link to clipboard
Copied
Hi all. In my work we do both English and French number formats. IE. $1,234 and 1 234 $, or 2.25% and 2,25 %. I've managed a grep f/c that changes the percents from E to F or F to E, but only if there's a decimal in the number. I cannot figure out how to change 5% (no decimal) without it finding the last digit before the percent sign (2.25%).
What would I add to my expression to find percentages that don't have decimals without also finding the last digit of a percentage with decimals? Note the number can be any number of digits long (IE 5%, 50%, 500%, 5000%, etc).
Thank you!
Copy link to clipboard
Copied
grudgemom wrote
What would I add to my expression
What expression? You did show any.
This one will find all % with or without preceding horizontal space, and insert Nonbreaking Space between the last digit and %:
find: \d\K\h?%
change to: ~S%
For CS6 and higher.
Not sure if this is what you’re looking for.
Copy link to clipboard
Copied
English --> French
Find: \d\K%
Replace by: ~S%
French --> English
Find: \d\K\h%
Replace by: %
Best,
Michel, for FRIdNGE
Copy link to clipboard
Copied
I currently have 4 greps set up for this
English whole number percent to French:
Find: (\d+)% Change: $1 %
English decimal number percent to French:
Find: (\d+)\.(\d+)% Change: $1,$2 %
(I appear to have deleted my English whole number percent to French grep)
French decimal number percent to English:
Find: (\d+),(\d+) % Change: $1.$2%
-----------------------------------------
This also gets a little more difficult when I need to change dollar amounts to French. Those require moving the $ to the back end of the number, replacing commas with spaces and periods with commas. Fun!
For English to French I have:
Find: \x{0024}(\d+)\.(\d+) Change: $1,$2 \x{0024}
(I realize this doesn't take into account numbers over 999 - that's my next step)
I'm using the What the Grep script from Jongware to help breakdown all the pieces for me and it doesn't recognize \h or \K so that puts a kink in my process...
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more