View Single Post
01-24-21, 05:18 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Lua does not use regex. It has a similar but limited engine:

https://wow.gamepedia.com/Pattern_matching

In this case, since I assume you want to keep the comma in the center, you need %d with parenthesis and then %# in the replacement argument

Lua Code:
  1. local text = "The number 45,678 is big, but 1,234 is small."
  2. text = string.gsub(text, "(%d),(%d)", "%1%2")
  3. print(text)
  4. -- should be: "The number 45678 is big, but 1234 is small."

The %d,%d captures any comma surrounded by numbers, the parenthesis "saves" the two numbers, and %1%2 outputs those two numbers in place without the comma.

Last edited by Kanegasi : 01-24-21 at 06:18 PM.
  Reply With Quote