Copy link to clipboard
Copied
I need to find currency and figgures, and flip the order throughout the report.
Example:
4,000 AED to be AED 4,000
200 AED to be AED 200
Find: ([\d,]+)(\h)(\u+)
Replace by: $3$2$1
(^/) The Jedi
OK!
(\d[\d,.]+\d)(\h)(\u+)
(^/)
Copy link to clipboard
Copied
Find: ([\d,]+)(\h)(\u+)
Replace by: $3$2$1
(^/) The Jedi
Copy link to clipboard
Copied
Thank you Jedi!
but what if I have a decimals in some numbers?
Copy link to clipboard
Copied
What kind? @FRIdNGE already included comma - [\d,]
But you can replace it with
[\d\.,]
You need to "escape" "." as alone it means "any character" so you need to add "\" before "." = "\."
Copy link to clipboard
Copied
Here are some examples of numbers
2,000,000 AED
5,340.76 AED
200.15 AED
Copy link to clipboard
Copied
([\d,.]+)(\h)(\u+)
(^/)
Copy link to clipboard
Copied
It did not work Jedi
Now it's finding only capital letters at start of paragraphs 🙂
Copy link to clipboard
Copied
Are you sure?
Copy link to clipboard
Copied
Sorry it works, but it's finding only capital letters at start of paragraphs as well.
Copy link to clipboard
Copied
OK!
(\d[\d,.]+\d)(\h)(\u+)
(^/)
Copy link to clipboard
Copied
Thanks a lot!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Just to build on @FRIdNGE's work a little, you can reduce the possibility of false positives by explicitly listing the standard currency codes (assuming you are using these):
(\d[\d\.,]+\d)\h(AED|AFN|ALL|AMD|ANG|AOA|ARS|AUD|AWG|AZN|BAM|BDS|BDT|BGN|BHD|BIF|BMD|BND|BOB|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHF|CLP|CNY|COP|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GGY|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HRK|HTG|HUF|IDR|ILS|IMP|INR|IQD|IRR|ISK|JEP|JMD|JOD|JPY|KES|KGS|KHR|KID|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRO|MRU|MTL|MUR|MVR|MWK|MXN|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLL|SOS|SRD|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|UYU|UZS|VEF|VND|VUV|WST|XAF|XCD|XOF|XPF|YER|ZAR|ZMK|ZWL)
I prefer the extra level of specificity. Then after running it, I would use FridNGE's more open grep and manually search through and check the one's this one missed—quite possibly none—because that will also validate the currency codes!
- Mark
Note: the forum software told me that I couldn't include the code for Barbadian dollar, so I took it out, but you may like to put it back in. *shrugs*
Copy link to clipboard
Copied
Thank you!
But I found that there is a code for all currencies
(\w+)
Copy link to clipboard
Copied
Sure, but that will also, incorrectly, target this text, for example:
The Company's 2023 AAA rating has suffered ...
Copy link to clipboard
Copied
I'm not an expert, and on my phone, but it should be a good start:
Find
([\d,]+) ([A-Z]+)
Change to
($2) ($1)
The only thing I'm not sure is the 2nd part - how to make it "not greedy"... Unless, you always have "AED" - this exact string, only letters - always CAPS - or letters + numbers?
Copy link to clipboard
Copied
Robert,
\h targets any space and tab.
Your "Change to" will replace:
200 AED
by:
(AED) (200)
So, remove the parenthesis to make your F/R work correctly here! 😉
Best,
(^/)
Copy link to clipboard
Copied
So, remove the parenthesis to make your F/R work correctly here! 😉
Best,
(^/)
By @FRIdNGE
Right, forgot about that.