This question already has answers here:
How to capitalize each word in a string using Swift iOS
(8 answers)
Closed 5 years ago.
I want output like this:
var String1 = "stack over flow"
var desiredOutPut = "Stack Over Flow"
Also, I want this output in TextField event named "textFieldDidChange" so it must be efficient as well.
var desiredOutPut = String1.capitalized
Related
This question already has answers here:
How do I encode/decode HTML entities in Ruby?
(8 answers)
Closed 6 years ago.
How can I extract the ascii code from a string and then convert it to char?
string = "a – b"
to
a – b
Use CGI library from ruby
CGI.unescapeHTML("a – b")
#=> "a – b"
This question already has answers here:
Finding out whether a string is numeric or not
(18 answers)
Closed 7 years ago.
How can I check, if searchView contains just numbers?
I found this:
if newText.isMatchedByRegex("^(?:|0|[1-9]\\d*)(?:\\.\\d*)?$") { ... }
but it checks if text contains any number. How can I do, that if all text contains just numbers in Swift?
Here is the solution you can get all digits from String.
Swift 3.0 :
let testString = "asdfsdsds12345gdssdsasdf"
let phone = testString.components(separatedBy: CharacterSet.decimalDigits.inverted).joined(separator: "")
print(phone)
you can use "^[0-9]+$" instade "^(?:|0|[1-9]\\d*)(?:\\.\\d*)?$"
This will accept one or more digits, if you want to accept only one digit then remove +
This question already has answers here:
Is it possible to include a quotation mark as part of an nsstring?
(7 answers)
Closed 7 years ago.
I am creating custom keyboard and for that I want to add quotation marks in an array for setting it as an button title. So how can I do these in Swift?
Here is a below code I tried:
symbolArray = ["+","-"," " "]
You have to escape the quotes with a backslash. "\""
This question already has answers here:
Printing optional variable
(15 answers)
Closed 7 years ago.
I am trying to print value on my table view row everything goes correct but value is printing like
println("\(cell?.textLabel?.text)")
Optional("Some text") instead of "Some text"
Is there any way in swift to print actual value?
It is printing an optional values so you need to unwrap it like:
if let yourCell = cell?.textLabel?.text {
println(yourCell)
}
Refer this Apple Document to know more about optionals.
print like this
println(cell.textLabel?.text)
This question already has answers here:
How to escape double quotes in string?
(3 answers)
Closed 10 years ago.
I have a string that has multiple " in it, which is written inside of #"" and of course, xcode sees this as me ending the #". Is there any alternatives I can use for #"" that would do the same thing?
It's done with escape chars. #"My name is \"Someone\". Blabla.";