Reputation: 513
I'm using google sheets and the REGEXEXTRACT
formula to extract all letters/numbers/hyphens in a range. In the examples below, I'm looking to remove the apostrophes.
'02 Blue Twisters
Blue Twisters '02
Blue Twisters 02-03
=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"\w+\w+\w+")))
=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"w.+")))
=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"w+")))
=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"[a-zA-Z0-9].+)))
=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"[a-zA-Z0-9]+")))
\w+
seems work as intended HERE but they don't seem to do the trick in Google Sheets. Some remove that first apostrophe, but not interior ones. Some don't remove anything.
Any ideas as to what I may be missing
Upvotes: 0
Views: 349
Reputation: 50799
extract all letters/numbers/hyphens in a range.
=REGEXREPLACE(A2, "[^A-Za-z0-9-]",)
Upvotes: 0
Reputation: 513
Thanks for the help folks, I came across two solutions. They're a bit complex but work.
=ARRAYFORMULA(IF(ISNUMBER(SEARCH("(",H3:H))=TRUE,TRIM(REGEXREPLACE(H3:H,"\(|\)","")),IF(ISNUMBER(SEARCH("'",H3:H))=TRUE,TRIM(REGEXREPLACE(H3:H,"'","")),H3:H)))
=ARRAYFORMULA(IF(DN3:DN="","",TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DN3:DN,"("," "),")"," "),"'"," "),":"," "),";"," "),"!"," "),","," "),"."," "))))
Upvotes: 0