Skip to main content
Hratch Derhagopian
Inspiring
November 22, 2023
Answered

GREP expression help needed

  • November 22, 2023
  • 2 replies
  • 1098 views

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

This topic has been closed for replies.
Correct answer FRIdNGE

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


OK!

 

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

 

(^/)

2 replies

Robert at ID-Tasker
Legend
November 22, 2023

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?

 

FRIdNGE
November 22, 2023

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,

(^/)

Robert at ID-Tasker
Legend
November 22, 2023
quote

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

 

Best,

(^/)


By @FRIdNGE

 

Right, forgot about that.

 

FRIdNGE
November 22, 2023

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

Replace by: $3$2$1

 

(^/)  The Jedi

Hratch Derhagopian
Inspiring
November 22, 2023

Thank you Jedi! 

but what if I have a decimals in some numbers? 

Robert at ID-Tasker
Legend
November 22, 2023

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