regex multiple replace

Hi folks,

I have to replace a large sql file, for money values between different locales.
‘123 456,89 Eu-’ to ‘$-123456.89’ (sometimes there is a “-” sometimes not)
I made a regex search and replace that is : ‘(\d+)(\s?)(\d+),(\d+) Eu(.?)’ (for search) and ‘$\5\1\3.\4’ for replace
but I also have numbers like ‘5,67 Eu’ or ‘1 234 567,89 Eu’ and my regex doesn’t match
I do the search-replace 3 times but is there a way to make it in one time ?

also do you know a FAST regex search and replace tool , accepting big files (100+MB)

thanks.

Set the ReplaceAllMatches option, you will only need to run Replace once.
http://documentation.xojo.com/api/text/regular_expressions/regexoptions.html#regexoptions-replaceallmatches

(example code here RegEx — Xojo documentation)

Tim, it’s not my question, sorry I didn’t explain enough.
I made 3 search-replace with 3 different regex strings : '(\\d+)(\\s?)(\\d+),(\\d+) Eu(.?)' , '(\\d+),(\\d+) Eu(.?)' and '(\\d+)(\\s?)(\\d+)(\\s?)(\\d+),(\\d+) Eu(.?)' to handle different number lengths.
I would like to have only one regex call to handle them all.

Ah, I misunderstood a little too. I’m afraid I haven’t been able to hack anything better with RegExRx.

@Jean-Yves Pochez - Had you tried using OR “|”? Check out my RegExRx entries to see if this is what you are looking for?

I knew about the OR “|” for the search part, didn’t know it could work too for the replace part.
will try that. thanks Milke.

[quote=471943:@Jean-Yves Pochez]I knew about the OR “|” for the search part, didn’t know it could work too for the replace part.
will try that. thanks Milke.[/quote]
I think you’ll see from the screenshot that it doesn’t.

Search Pattern:

(?x)

# Word break
\\b

# Lookahead to confirm
(?=(?:\\d+\\x20)*\\d{1,3},\\d+\\x20Eu-?)

# Number groups
(?:(\\d{1,3})\\x20)? # \\1
(?:(\\d{1,3})\\x20)? # \\2
(?:(\\d{1,3})\\x20)? # \\3
(?:(\\d{1,3})\\x20)? # \\4
(?:(\\d{1,3})\\x20)? # \\5

# Main
(\\d{1,3}) # \\6

# Ignored comma
,

# Decimal
(\\d+) # \\7

# Ignored text
\\x20Eu

# Possible negation
(-?) # \\8

Replacement pattern:

\\$\\8\\1\\2\\3\\4\\5\\6.\\7

because he did not use the correct replacement pattern ?

Well Master Kem has spoken… Thanks !
did not try it but I’m confident it will work…

Well after reading it again and again, I still don’t understand how it works !

well … it works !

I’d hoped the comments would help, but let me explains some of the tokens:

  • \d # any digit
  • \d{1,3} # series of 1 to 3 digits
  • \x20 # a space
  • (? … ) # A non-capturing group
  • (?:(\d{1,3})\x20)? # 1 to 3 digits followed by a space (optional), but only the digits are captured

Does that clear it up?