Reputation: 437
Trying to get rid of specific numbers in a cell using REGEXEXTRACT & SUBSTITUTE:
Start with | Output |
---|---|
1. Charlie100db 2.Charlie 100dc, 3charlie 100 dcc,4 100charlie, 5. 100 charlie 1. Charlie100db, 2.Charlie 100dc, 3charlie 100 db, 4 100charlie, 5. 100 charlie, 6. Charlie100db Charlie100db | Charlie100db, Charlie 100dc, charlie 100 dcc, 100charlie, 100 charlie, Charlie100db, Charlie 100dc, charlie 100 db, 100charlie, 100 charlie, Charlie100db Charlie100db |
REGEXEXTRACT((SUBSTITUTE(A3,CHAR(10),", ")), "((?:\d{3,}|[a-zA-Z]\w+[^.])+)")
The Regex works to match test:
((?:\d{3,}|[a-zA-Z]\w+[^.])+)
Test code highlights as can be seen here
I believe this code should work in Google Sheets but it is failing, Im not sure why?
The shared google sheet is here: https://docs.google.com/spreadsheets/d/1SssStTS63CztmUjjMRv3m2MBPAmPPmRT1CZI4Ym2_8A/edit?usp=sharing
Starting with the following text in A2: Charlie100db 2.Charlie 100dc, 3charlie 100 dcc,4 100charlie, 5. 100 charlie 1. Charlie100db, 2.Charlie 100dc, 3charlie 100 db, 4 100charlie, 5. 100 charlie, 6. Charlie100db Charlie100db
REGEXREPLACE(A2,"((?:\d{3,}|[a-zA-Z]\w+[^.])+)","")
Result=1. 2. 3 4 5. . 2.3 4 5. 6.
However, using RegexExtract does not seem to work
REGEXEXTRACT(A2, "((?:\d{3,}|[a-zA-Z]\w+[^.])+)")
Result=Charlie100db
Does anyone have a solution to fix this formula so that it works?
Upvotes: 0
Views: 67
Reputation: 1
try:
=TRIM(REGEXREPLACE(REGEXREPLACE(A2, "\n\d\.?|\d\.", ), ", \d|,\d", ", "))
Upvotes: 1