string - Lua: RegEx to Pattern -


simple problem...i need turn regex pattern...

"\[\"([0-9]+)\"\]" 

into lua pattern.

i doing replace bunch ["x"] lines [x] in string x number -∞ or +∞...so that's limitation. need port lua patterns can use in string.gsub.

find: "\[\"([0-9]+)\"\]" 

also, how remove " " around number? need pattern that. if me out, appreciate it.

you try this.

> f = "foo [\"12\"] bar" > x = string.gsub(f, "%[\"(%d+)\"%]", "[%1]") > print(f) foo ["12"] bar > print(x) foo [12] bar 

\d matches digits represented %d in lua.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -