Reputation:
I have these strings:
"test 123"
"Test 123"
"Tes 234"
"T 123"
"abc 123"
I want to remove the strings "test"
, "Test"
, "TEST"
, "T"
. I want something like this:
"123"
"123"
"234"
"123"
"abc 123"
I tried this:
string.sub(/\s*[\w']+\s+/, "")
but it removes "abc"
. Please guide me on how to solve this.
Upvotes: 1
Views: 74
Reputation: 32933
I would do
string.gsub(/t|test/i,"").strip
EDIT: if you want to remove "T", "Te", "Tes" or "Test", followed by a space, in any combination of upper/lower case, then do
string.gsub(/te?s?t?\s/i,"").strip
Upvotes: 6