I have a column in Google Sheets that has phone numbers with the following formats:
(904) 123 4567
+62 123 4567
+12345678
How can I create another column that automatically removes "+", "(", ")" and spaces to produce 9041234567?
Thanks
You can replace all non-digits with nothing.
=ArrayFormula(regexreplace(A2:A4&"", "\D+",))
Change range to suit and/or use an open-ended range
=ArrayFormula(if(len(A2:A), regexreplace(A2:A4&"", "\D+",),))
You can just use REGEXREPLACE to remove the characters you don't want:
=REGEXREPLACE(A1; "[ \(\)\+]"; "")
The expression used [ \(\)\+], removes the character space, right and left parenthesis and the plus sign. Simply add all other characters you want to remove.
Related
Goal:
I want a CSV file as my result. I want to change the space char to a comma on each line of data. BUT, I also need the data for the 3rd field (Description) to remain as is with original space chars. Each line of data is terminated with a newline char.
Flipping spaces to commas on every line is easy with regex. But how do 'bookend' the string of text which will then become the 3rd/Description field and preserve its spaces? Currently I manually change commas back to spaces just in that text string. Painful.
Example of Final result needed (including column names)
Transaction Date,Posting Date,Description,Reference Number,Account Number,Amount
12/23,12/24,GOOGLE*DOMAINS SUPPORT.GOOGLCA,7811,8550,12.00
My sample data:
12/23 12/24 GOOGLE*DOMAINS SUPPORT.GOOGLCA 7811 8550 12.00
01/02 01/04 CREPEVINE - OAKLAND OAKLAND 234567 CA 1087 8220 16.32
01/06 01/07 AB* ABEBOOKS.CO J6YDBX HTTPSWWW.ABEBWA 6289 85332 6.98
01/20 01/21 SQ *BAGEL STREET CAFE Oakland CA 2313 44444 24.43
A few of My Regex attempts
This cmd changes spaces to commas over all 5 lines by combining it with Join cmd. Easy.
And just fyi: "\n" would not work for some reason so I do the <Ctrl+Enter> keys to inject a newline char, ie the two lines. For now it orks fine.
=regexreplace(join("
",A1:A5)," ",",")
RESULT:
12/23,12/24,GOOGLE*DOMAINS,SUPPORT.GOOGLCA,7811,8550,12.00
...
01/02,01/04,CREPEVINE,-,OAKLAND,OAKLAND,CA,1087,8550,16.32
...
Here is my poor attemp to bookend the description field, then flip commas back to spaces, but no luck either.
=REGEXREPLACE(A1,"(,[A-Z]+[A-Z],)"," ")
How do I craft a regex to do this?
cheers,
Damon
Using Regex101 to reverse learn how you did it
Can you try:
=index(if(len(A:A),regexreplace(A:A,"(?U)(.*) (.*) (.*) (\d[^A-Za-z]*) (\d.*) (\d.*)","$1,$2,$3,$4,$5,$6"),))
I have a list of numbers in a few formats that may or may not include a dot and a comma. The numbers are locked in a string. For example:
hello 1,000 goodbye
hola 2,000.12 ciao
Hallo 3000.00 Auf Wiedersehen
How can I extract the numbers?
I don't care if the comma is added but the dot is obviously important.
I need the regular_expression to be used in REGEXEXTRACT (and the rest of the REGEX formulas.
The output should be:
1000
2000.12
3000.00
Supposing that your raw data is in A2:A, use this in B2 (or the second cell) of an otherwise empty column:
=ArrayFormula(IF(A2:A="",,IFERROR(VALUE(REGEXEXTRACT(A2:A,"\d[\d,\.]*\d")))))
The REGEX portion reads, in plain English, "Extract any portion that starts with a digit followed by any number of digits, commas or periods (or none of these) and ends with a digit."
You will likely want to apply Format > Number > Currency to the results column.
I have text A B c in a spreadhsheet cell.
How can I remove the whitespaces? =Trim is for leading and closing whitespaces.
=REGEXREPLACE(A1, "\s", "") where A1 is your cell with spaces. It uses a regular expression to match any whitespace character, including spaces, tabs, and newlines. If you only want to remove spaces, then use =REGEXREPLACE(A1, " ", "").
Use the Substitute function like this =SUBSTITUTE(B3, " ", ""). Hope it helps.
I want to add comma in spread sheet as a superscript like :
in this ->> ¹,²
comma is not as superscript. Is there any way out for comma to be added as superscript in google spreadsheet?
For 1 and 2 and many others, there is a function available in sheet like =char(178)
however I am ot able to find the code for comma.
Answer:
As there is no Unicode for a superscript comma, you can not do this.
More Information:
Not all characters have superscript-versions set in unicode. You can see the full list of available superscript characters here.
You can either use the dot operator (U+2265) ⋅, or the modifier letter apostrophe (U+02BC) ʼ as separators instead, if you wish to hard code this. I am of the personal opintion that the dot operator looks more like a comma, but they both appear as below:
¹⋅² (dot operator)
¹ʼ² (modifier letter apostrophe)
As Google Sheets isn't a word processing application, there is no direct in-built way to make text appear as superscript, akin to <sup>1,2</sup> in HTML:
1,2
References:
Unicode subscripts and superscripts - Wikipedia
I know how to split text using other delimiters such as a comma, equal sign etc. I am having trouble for examples that require a number delimiter.
A typical split formula that uses a comma delimiter would look like this:
=SPLIT(A1, ",")
I am struggling with splitting text that looks something like this. The delimiter here is a number.
This is a random text of 20 characters but could be 30 characters as well.
Output should be
This is a random text of | 20 | characters but could be | 30 | characters as well.
Please help. Thanks
Try the following:
=SPLIT(REGEXREPLACE(A1,"\d+","|$0|"),"|")
Maybe better, to remove spaces:
=SPLIT(REGEXREPLACE(A1,"\s*(\d+)\s*","|$1|"),"|")