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.
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'm having some trouble to find the right pattern to get the string I want.
My starting string is :
,,,,C3:,D3,E3,F3,,
I would like to have
C3: [D3,E3,F3]
I would like to replace each starting commas by double space
Replace coma after colon by double space and left square bracket
Replace trailing commas by right square bracket
For now, I tried this :
> a = ",,,,C3:,D3,E3,F3,,"
=> ",,,,C3:,D3,E3,F3,,"
> b = a.gsub(/^,*/, " ").gsub(/(?<=:),/, " [").gsub(/[,]*$/,"" ).gsub(/[ ]*$/, "]")
=> " C3: [D3,E3,F3]"
> b == " C3: [D3,E3,F3]"
=> false
I can't reach to replace each starting comma by a double space to obtain 8 spaces in this case.
Could you help me to find the right regexp and if possible to improve my code, please ?
To replace each starting comma with a double space, you need to use \G operator, i.e. .gsub(/\G,/, ' '). That operator tells the regex engine to match at the start of the string and then after each successful match. So, you only replace each consecutive comma in the beginning of the string with .gsub(/\G,/, ' ').
Then, you can add other replacements:
s.gsub(/\G,/, ' ').sub(/,+\z/, ']').sub(/:,+/, ': [')
See the IDEONE demo
s = ",,,,C3:,D3,E3,F3,,"
puts s.gsub(/\G,/, ' ').sub(/,+\z/, ']').sub(/:,+/, ': [')
Output:
C3: [D3,E3,F3]
To construct the desired string, one needs to know:
the number of leading commas (the size of the string comprised of the leading commas)
the string following the leading commas up to and including the colon
the string between the comma following the colon and two or more commas
It is a simple matter to construct a regex that saves each of these three strings to a capture group:
r = /
(,*) # match leading commas in capture group 1
(.+:) # match up and including colon in capture group 2
, # match comma
(.+) # match any number of any characters in capture group 3
,, # match two commas
/x # extended/free-spacing regex definition mode
",,,,C3:,D3,E3,F3,," =~ r
We can now form the desired string from the contents of the three capture groups:
"#{' '*$1.size}#{$2} [#{$3}]"
#=> " C3: [D3,E3,F3]"
There are some marks just like exclamation mark or question mark, and I found iOS escape them by default. How to speak them out?
Example: 'Tom! First name' or '? My last account'.
You can speak these words to add these marks.... just check
apostrophe ‘
open bracket [
close bracket ]
open parenthesis (
close parenthesis )
open brace {
close brace }
open angle bracket <
close angle bracket >
colon :
comma ,
dash -
ellipsis …
exclamation mark !
hyphen –
period / point / dot / full stop .
question mark ?
quote "
end quote "
begin single quote '
end single quote '
semicolon ;
Typography Result
ampersand &
asterisk *
at sign #
backslash \
forward slash /
caret ^
center dot ·
large center dot •
degree sign °
hashtag / pound sign #
percent sign %
underscore _
vertical bar |
I have to display "#" in the UITextview content and after to put some information.
I looked on the internet via google but I didn't find an explanation which make
me understand the good approach.
Can you help me with some extra advice ?
Thanks !
You can simply do it like this:
_textView.text=#"#Hi Hello"; result will be #Hi Hello
However if you want to use " in the text you need to append it to backslash \
_textView.text=#"#Hi \"Hello"; result will be #Hi "Hello
You can enter almost all special characters without any problem, but you need to take care for the double quotes:
_textView.text=#"#Hi \"Hello * ! # # $ % ^ & ( ) _ + - [ ] ; ' {} <> ,. / ? : \" ";