• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
11

GREP expression help needed

Participant ,
Nov 22, 2023 Nov 22, 2023

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

TOPICS
How to , Scripting , Type

Views

373

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Guide , Nov 22, 2023 Nov 22, 2023

Find: ([\d,]+)(\h)(\u+)

Replace by: $3$2$1

 

(^/)  The Jedi

Votes

Translate

Translate
Guide , Nov 22, 2023 Nov 22, 2023

OK!

 

(\d[\d,.]+\d)(\h)(\u+)

 

(^/)

Votes

Translate

Translate
Guide ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Find: ([\d,]+)(\h)(\u+)

Replace by: $3$2$1

 

(^/)  The Jedi

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Thank you Jedi! 

but what if I have a decimals in some numbers? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

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 "." = "\."

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Here are some examples of numbers

2,000,000 AED

5,340.76 AED

200.15 AED

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

([\d,.]+)(\h)(\u+)

 

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

It did not work Jedi

Now it's finding only capital letters at start of paragraphs 🙂 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Are you sure?

 

Capture d’écran 2023-11-22 à 13.24.58.pngCapture d’écran 2023-11-22 à 13.25.14.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Sorry it works, but it's finding only capital letters at start of paragraphs as well. 

Screen Shot 2023-11-22 at 4.41.38 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

OK!

 

(\d[\d,.]+\d)(\h)(\u+)

 

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Thanks a lot! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

LATEST
quote

OK!

 

(\d[\d,.]+\d)(\h)(\u+)

 

(^/)


By @FRIdNGE

 

Is "." in [] treated as "." or as "any character" ?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

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*

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Thank you! 

But I found that there is a code for all currencies 

(\w+)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Sure, but that will also, incorrectly, target this text, for example:

The Company's 2023 AAA rating has suffered ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

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?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2023 Nov 22, 2023

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,

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

quote

So, remove the parenthesis to make your F/R work correctly here!  😉

 

Best,

(^/)


By @FRIdNGE

 

Right, forgot about that.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines