WoW:API gsub: Difference between revisions

1 byte removed ,  15 August 2023
m
Move page script moved page API gsub to WoW:API gsub without leaving a redirect
(+ strreplace)
m (Move page script moved page API gsub to WoW:API gsub without leaving a redirect)
 
(One intermediate revision by one other user not shown)
Line 20: Line 20:
  bnanaa  2
  bnanaa  2


If the replacement is a function, not a string, the arguments passed to the function are any captures that are made. If the function returns a string, the value returned is substituted back into the string. Just like string.find() we can use regular expressions to search in strings. Patterns are covered in the [http://lua-users.org/wiki/PatternsTutorial Patterns Tutorial on Lua-Users.org], and [[HOWTO: Use Pattern Matching]].
If the replacement is a function, not a string, the arguments passed to the function are any captures that are made. If the function returns a string, the value returned is substituted back into the string. Just like string.find() we can use regular expressions to search in strings. Patterns are covered in the [http://lua-users.org/wiki/PatternsTutorial Patterns Tutorial on Lua-Users.org], and the [[pattern matching]] HOWTO.


  > = string.gsub("Hello Lua user", "(%w+)", print)  -- print any words found
  > = string.gsub("Hello Lua user", "(%w+)", print)  -- print any words found
Anonymous user