Google's LibPhoneNumber package : 7777777779 and 2234567890 are invalid USA phone numbers? [closed] - phone-number

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 9 years ago.
Improve this question
Question : I am using Google's LibPhoneNumber package to validate phone numbers in Java. When the country is set to US, 7777777779 and 2234567890 are being classed as invalid numbers, but 7866438057 is valid. Why is this? I've tried reading why they may be invalid, such as on the US phone number wikipedia page, but I see no answer.
Code :
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
PhoneNumber parsedNumber = phoneUtil.parse(number, iso3Country);
//Is it a valid number for the locale?
if (!phoneUtil.isValidNumber(parsedNumber)) {
//TODO Throw error!
}
}

It's probably because 777 and 223 aren't U.S. area codes.
I think this is the official list of area codes in the North American Numbering Plan, which includes the U.S., Canada, and many smaller countries.

Related

Return a column range in which a string is in a cell [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 5 months ago.
Improve this question
Here is an example sheet:
https://docs.google.com/spreadsheets/d/1P91qqhClA8oO3-N9OGSxrFH-6lXxttZ3IN4bIGRGjHw/edit?usp=sharing
I am trying to get the column range returned in when the string in INPUT!B1 can be seen in DATABASE!A2:A into INPUT!C1:C3
You can use FILTER() function.
=FILTER(DATABASE!A:C,DATABASE!A:A=B1)
VLookup(), Index/Match(), QUERY() all these functions will work for you.

Telephone mask (number format) with variable lenght [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 was looking for the best solution to mask cells with telephone numbers like the example:
(+55 11) 99999-9999
Normally I'd use (+## ##) #####-#### as a custom number format. The problem is that the length of the number may vary. Nine numbers for cellphones and eight for home numbers. So, with a mask like that, an eight number phone would be formated like (+5 51) 19999-9999
Well, while posting this question I found the solution I wanted using Custom Number Format with conditions based on the number value.
[<=999999999999](+00 00) 0000-0000; [>999999999999](+00 00) 00000-0000;

In Ruby, how do I find all the letters after the last number in a string? [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 6 years ago.
Improve this question
I'm using Ruby 2.4. I have a string with letters and numbers, something like
str = "123abc234abb"
How do I find all the letters occurring after the last number in the string? For example, if I applied the function to the above, it would yield
abb
You could use a positive lookbehind:
"123abc234abb"[/(?<=\d)?[a-zA-Z]+\z/]
#=> "abb"
Try this
str.rpartition(/\d+/).last
How does this work?
rpartition splits the string into three parts, using reverse matching
last picks the post-match part from the three results

What is the best way to check if a string contains any numbers? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I am creating a check to make sure the user remembers to enter the house number as well as road number in the address.
how would I go about checking to see if a NSString contains 0-9 number characters?
This could be as simple as using rangeOfCharacterFromSet:
NSCharacterSet * set = [NSCharacterSet characterSetWithCharactersInString:#"0123456789"];
if ([aString rangeOfCharacterFromSet:set].location != NSNotFound) {
NSLog(#"This string contains illegal characters");
}
You could also give a look at regular expressions, if you would like to do something fancier with your validation, but in order to just check if a string contains any number, the above is enough.
Have a look at -[NSString (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet]
and +[NSCharacterSet (id)decimalDigitCharacterSet].

Limit a NSMutablestring's length [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 9 years ago.
Improve this question
I am working on a calculator App.
The NSMutablestring is used for calculation E.g "5-3*8-(-1)/77".
But the label can't display endless an NSMutablestring, so is there have any way to limit NSMutablestring's length?
(not too long, I want the NSMutablestring's length to be less than 100).
You can get the first 100 characters of a string as follows:
NSString *first100chars = [myString substringToIndex:100];
However, it sounds like you need to prevent the user from actually entering a string this long, which is a different problem. The comments to your question give examples of other people asking similar questions (e.g. Set the maximum character length of a UITextField), I suggest you check those.
This is a job for an NSFormatter subclass. That's exactly what it's for.

Resources