Regex with single quote (') not validating single quote [closed] - swift

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm using following regex to validate name:
^[a-zA-Z]{1}[a-zA-Z.' ]{1,20}$
Single quote is mentioned in the second range. However, when I validate a string against this regex, single quote (') invalidates the match. Here's my code:
let nameRegEx = "^[a-zA-Z]{1}[a-zA-Z.' ]{1,21}$"
let nameTest = NSPredicate(format:"SELF MATCHES %#", nameRegEx)
let isNameValid = nameTest.evaluate(with: name)
I've tried \' but no use.

Turns out textField.text returns ’ and not '. Changing the character resolved the issue.

Related

Replace letters in a word with a character [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I need to replace certain letters in a word with a character.
I'm stuck. How can I fix it?
It looks like you already have most of the code. You just need to add the letters that don't need to be replaced and are not in the consonants list.
To do this, I would use an if-else instead of an if in your loop. This will allow you to replace letters that are in the consonants list and add letters that don't need to be replaced to the final word.
It would look something like this:
Note that the consonants list has the characters that are to be replaced in word word.
This should give you what you are looking for.

ISO-8859-9/Latin-9 encoding [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I know it exist ISO-8859-9/Latin-5 or ISO-8859-15/Latin-9, but recently I had to manage some messages encoded with ISO-8859-9/Latin-9 format.
What does it exactly mean?
There is ISO-8859-9 which is called Latin-5.
And there is ISO-8859-15 which is called Latin-9.
Yes, it is confusing. In my opinion it's simplest to always only use the ISO-8859-n moniker. That avoids potential confusions.
So "ISO-8859-9/Latin-9" is probably a typo (or someone wrongly thought that the suffix is identical for the "ISO-8859-" and the "Latin-" prefix).
Depending on the source of the data, you can guess which one they meant. ISO-8859-9 is used for Turkish text and ISO-8859-15 is basically the modern replacement for ISO-8859-1 (covering most of Western Europe, mostly used because it has the € symbol).
Source: ISO/IEC 8859 Wiki page.

Rust Command Line Arguments [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I'm experimenting with command line arguments in Rust.
Windows Power Shell.
if let Some(a) = env::args().nth(1) {
println!("parâmetro é {:?}", &a);
} else ...
ARG = "Qu'il" prints "parâmetro é Qu\'il" (ok)
ARG = Qu'il (results in apparent infinite loop)
ARG = Qu\il (idem)
So, what's the proper way to handle this (the error)?
Thanks in advance.
I can't really discern what error you are referring to, so I'll explain the reasoning for the behavior you are seeing:
You are using the format specifier {:?} which makes Rust print the string in a debug-friendly manner. If you use println!("parâmetro é {}", &a); instead you'd see parâmetro é Qu'il
This is not an infinite loop. Apostrophes (') are special characters in PowerShell to define a literal string. The reason why nothing is happening is that PowerShell is waiting for you to write the rest of the string and finish with another apostrophe.
Like nr. 1
See more here:
About literal strings in PowerShell
Can I use a single quote in a PowerShell 'string'?

Get all diacritics for a given character in Swift? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I get a string or array consisting of all the diacritics for a given character in swift?
Thanks,
Michael
The Unicode standard defines 112 common diacritical marks, each of them can combine with every character a - z (and their uppercase):
let characters = Array("abcdefghijklmnopqrstuvwxyz".characters)
for char in characters {
for i in 0x0300...0x036F {
let diacritic = UnicodeScalar(i)
var str = String(char)
str.append(diacritic)
print(str, terminator: " ")
}
print()
}
What you see on the iPhone keyboard is a select number of diacritic marks that Apple has chosen for each character, possibly based on the keyboard's language. You would have to do the same if you don't want to overwhelm your users with choice.

Looking for special characters in Google [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Do you know how to look for special characters with google...?
I'm looking at bash code and there's the ## operator. I would like to know what It does but I wasn't able to figure out a way to protect the character (I'm not sure it's even possible).
This is particularly annoying when you're looking for some code patterns, some characters are always ignored.
Update: this answer is no longer applicable as of 2017. See https://blog.google/products/search/improvements-searching-special-characters-programming-languages/
Google strips most punctuation from queries, as described here, so it won't help you with the bash syntax.
It's very easy to search for the string "##" in the bash documentation: Just run "info bash", hit "s", and enter "##" as the search string.
google strips puntuation, imho, because:
it's somewhere used for special search (chars like - to exclude, +to add and 10..20 to specify a range)
to avoid spammers to get email addresses (characters like # or .)
in my experience, it's even impossible to escape special characters.
the only solution I found, by now, is using yahoo http://it.search.yahoo.com/