View Single Post
08/16/15, 09:23 PM   #2
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
It's just not recognizing the beginning anchor (^).
Lua Code:
  1. /script string.gsub("une rune de puissance", "^(%l+) ", function(str) d(str) end)
  2.  
  3. une
  4. rune
  5. de

As far as the number of matches, it's correct (without the beginning anchor). It matches 3 words with spaces after, even though it can only replace two.

I suppose as a hack way, you could use a function and only replace the first time it's called:
Lua Code:
  1. function singleSub(str, match, lookup)
  2.     local inReplace = true
  3.     return str:gsub(match, function(str)
  4.         if not inReplace then
  5.             return str
  6.         end
  7.         inReplace = false
  8.         return lookup[str] or str
  9.     end)
  10. end
The fix for ZOS would be to see why ^ is being ignored in patterns.