In the first case, the pattern works 2 times: for 30 x 4 and for 0 x 900
In the second case, only once for 3 x 4 and then for x 90 there is no longer a match.
And in general, isn't it easier to replace spaces with the necessary characters?
local s = "3 x 4 x 90"
s = s:gsub('%s+', '\u{2009}')
print (s)
Result:
3u{2009}xu{2009}4u{2009}xu{2009}90