How can i get prefix pf phone number? - iphone

Hello everyone I am trying to get prefix of phone numbers in order to get the actual phone number without country dialing code. How can I achieve this?
Please note that the phone numbers can be
123456789
0099123456789
+9912345678
or any other formats with country code and area code etc..

if you tried like this then it will help some what but not sure ,
NSString *str=[PhoneNumber substringToIndex:[PhoneNumber length]-10];

Taking a look at the amount of different prefixes you can have List of country calling codes [wikipedia] and Internatioal dialing prefix [wikipedia], one could reach the conclusion that without narrowing the area down you'll probably not get very far with this.
If however you'll be handling phone numbers from a specific region to another specific region you might be able to come up with something.

Related

Remove country code code from phone number

I am receiving the contact list from device, now I want to remove country codes from numbers maybe one number will be have the country code with +1 or 01
How can I do it , I want to remove country codes from all numbers any country
Here's what I would do. There are plenty of resources online that has a list of country codes. I'll download them and compare them with each number in the contact list. And finally run whatever removal operation I have.
Edit: Before running the above algorithm, I would first clean the data.
Remove all whitespaces.
Replace the leading 0 with + or vice versa depending on the available dataset
you can store them in a vector and when you retrieve the information you can skip the first elements which belongs to the country code. usually telephone numbers have 9 numbers besides country code. you can fix the output array indexes.
only way to remove the country code from the phone number is after making sure to which country the phone number belongs to.
if you are sure about +1 or 01 or any first two digit is the country code,
number.substring(2);
will give you the number.
if this is still relevant.
since all numbers are 10 characters you can do
number.substring(number.length - 10)
this would take the last 10 digits regardless of the country code with plus or not
aah hey, this question was asked earlier but anyways will answer it ..
THE FOLLOWING CODE IS WRITTEN IN JAVA
there are 2 ways to solve this !
1st
String abc="+91 9000000009";
abc=abc.replaceAll(" ","");
int count=0;String Num="";
for(int i=abc.length()-1;i>=0;i--)
{
if(count<10)//change number 10 according to the preferred number of digits of Phone Number Excluding country code
{
Num=abc.charAt(i)+Num;
count++;
}
else
{
break;
}
}
System.out.println("Number Without Country Code : "+Num);
2nd
String abc="+91 9000000009";
abc=abc.replaceAll(" ","");
String Num1=abc.substring(abc.length()-10);//change number 10 according to the preferred number of digits of Phone Number Excluding country code
System.out.println("Number Without Country Code : "+Num1);
Both The Ways Work Fine
but in the second way if then is less than '10' then it would cause a error !

Scanning invoices using OCR in swift

I am currently working on scanning invoices with OCR scanning. All invoices use the "OCRB" font, and have the same formatting.
The bottom of a sample invoice looks like this
This is what the user needs to scan.
I have tried many different libraries to detect what I want. But most libraries doesn't give me the correct result. The best result came from Firebase ML Vision text recognition.
But the resulting output I get is this:
I can calculate if the values are correct, except for the amount, presented in the middle. In this case it's presented as "3557 00" but if the user moves the camera a bit further to the right, the result I get is "557 00". Since both MLKit and other libraries cuts around the word, I have no idea if the full sum is presented or not.
If I would get a single space before the word, I could get that there is a full "word", in this case a sum.
Anyone has any ideas of how what library to use to get the best result?

Position of Range-Object in Excel

I am trying to figure out how to get the position of a selected Range in an Excel(2007)-Worksheet. Is there something similar to $self->{EXCEL}->ActiveCell->Row for Cells (self->{EXCEL} being an Excel-Object)?
I tried ->Selection->Range, ->ActiveSheet->Range, and as a workaround ->Range->Row, ->Range->Rows both with an Excel- and a Worksheet-Object with no success.
The most fancy output being two Cell-Objects, one for the start-address, the other one end-address.
Thanks for any helpful hints!
=== Update ===
I now use successfully the command $self->{EXCEL}->Selection->Address(); to retrieve the address of the selected range. By default I get the address in "A1"-format ($E$1:$G$14). Using ->Address("ToReferenceStyle:=xlR1C1") however does not return the address in "R1C1"-format as I would have expected...
Faulty command? Ignorant Excel? Thanky again on any helpful hint!
How about ->Selection->Address? I'm not sure on the format, but the address property of the selection (range object) will give you the address of the range for example. $A$1:$B$7. You would be able to parse the start and end by splitting the string on the colon.
To address your new questions... I'm not even sure if what you're using, but the third parameter of the address method is ReferenceStyle not ToReferenceStyle. So I would try either ->Address(ReferenceStyle:=xlR1C1) or ->Address(,,xlR1C1)

iOS: Valid zip code check

Question: How would one write a function to check and return whether or not a string (NSString) contains a valid zip code worldwide.
Additional info: I am aware of RegEx in iOS. However I am not so fluent at it. Please keep in mind this should accepts anything valid in any country as true.
Examples
US - "10200"
US - "33701-4313"
Canada - "K8N 5W6"
UK - "3252-322"
etc.
Edit: Those who voted down or to close the question, please do mention why. Thank you.
^[ABCEGHJKLMNPRSTVXY]\d[A-Z][- ]*\d[A-Z]\d$
Matches Canadian PostalCode formats with or without spaces (e.g., "T2X 1V4" or "T2X1V4")
^\d{5}(-\d{4})?$
Matches all US format ZIP code formats (e.g., "94105-0011" or "94105")
(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]\d[A-Z][- ]*\d[A-Z]\d$)
Matches US or Canadian codes in above formats.
UK codes are more complicated than you think: http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
I suggest you don't do this. I've seen many websites that try to enforce zipcodes, but I've never seen one get it right. Even the name zipcode is specific to the US.
In other words:
- (BOOL)isValidZipCode: (NSString *)zip {
return YES;
}
I was originally going to write [zip length] > 0, but of course even that isn't guaranteed.
Each country that uses postcodes/zip codes usually has their own format. You are going to be hard-pressed to find a regular expression that matches any worldwide code!
You're better off adding a country picker that determines the regular expression (if any) to be used to validate the zip code.
As an aside, the postcode you have given as a UK example is not correct. A decent UK regex is:
^(^gir\\s0aa$)|(^[a-pr-uwyz]((\\d{1,2})|([a-hk-y]\\d{1,2})|(\\d[a-hjks-uw])|([a-hk-y]\\d[abehmnprv-y]))\\s\\d[abd-hjlnp-uw-z]{2}$)$

Get Zipcodes List by giving my current point zipcode inside a radius

I need to find if the given zip code is within the required radius. For example, if the user has entered 20910, it should be able to determine if it's within 5 mile radius of 20814. Is there a way to do it? Google API or something? Please help.
I'm using C# as the programming language.
I think it's called the havershine formula...
Havershine Example - google it for more