My app uses the user's phone number as unique username, and it also sync all of his contacts so he can send them messages.
So, I need a way to format all the phone numbers I'm getting from the phone's address book.
I need to know for a given number:
Country code (if exists).
The number itself.
And if the number includes some international call prefix, it should be remove from the number.
So for example if I have a contact with the number
014 1 3728834122
The format should tell me that the country code is 1 and that the number is 3728834122 (I don't care about the 014 prefix)
What interesting is that the native phone address book seems to know how to format the number, I can see it while typing a new number, it added () or spaces when needed.
So my question is:
Can I query the native address book for a given number, what's his country code & number?
Does anyone knows a good library that do this kind of formatting?
Related
I am storing phone numbers in the database in the user model in various formats. All the followings are possible.
+306974135662, 306974135662, 30 6974135662
Then from the front-end, I am getting a specific format that has the plus sign and no spaces.
+306974135662
I want to write a mongoid query that matches all the above formats. Is that possible?
User.where(phone: params[phone])
should return all 3 users with phone numbers +306974135662, 306974135662, and 30 6974135662
Option 1: store phone numbers as they are entered, use regular expressions for matching.
Option 2: store phone numbers as they are entered in one field. In another field store canonicalized representations of the phone numbers (the second one in your example). Match against the canonicalized representation.
The second option costs additional disk space, memory and pre-processing but allows queries to be simpler and faster.
I'm trying to do a little bit of analysis on the topics of emails I receive. I have the emails in a Google-sheet in the format below. I'm trying to count how often 'privacy' or 'confidentiality' are mentioned. My challenge is that pretty much every email signature mentions one of those words, so when i use SEARCH every cell returns TRUE.
Most email signatures start with similar phrases, so I tried deleting anything after those phrases with this formula:
=ArrayFormula(TRIM(LEFT(B1:B,MIN(IFERROR(FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B1:B),LEN(L2))))))
Column B is the column with the email body text in.
However that seems to be deleting text that follows words that aren't in my search (deleting everything after 'not' instead of 'IMPORTANT NOTICE' for instance).
Could anyone advise on either:
what's wrong with my above search
an alternate way of searching for 'privacy' and 'confidentiality' without including text from email signatures.
Example table:
|email title|email body|
|-----------|----------|
|Do you want to buy my stuff| Hi there, I'd like to know if you'd like to buy this thing I want to sell you. IMPORTANT: this email is private|
|two-for-the-price-of-one| I've a great offer for you! This email and attachments are private & confidential|
|Last chance to buy stuff!| Can we have a private call about whether you want to buy my stuff yet?|
In the example above I want to count row 3, but not rows 1 & 2, as the 'private' and 'confidential' mentions in 1 & 2 are in the signature.
Thanks!
I think I understand the error that you've described is occuring with your formula. Once the formula finds one of the values you are using to try to identify an email signature, such as " Important notice", and returns the location of that text, let's say position 96, it then uses 96 for all of the cells, like this: LEFT(B1:B,96). So you might not be able to do the compound arrayformula of an arrayformula that you are trying.
Using the formula like this, in B2, and dragging it down, should work though:
=ArrayFormula(TRIM(LEFT(B2,MIN(IFERROR(
FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B2),
LEN(L2))))))
Note: I'm not sure what value is in your L2.
But for the overall approach, it really depends on how well your terms to identify email signatures work, so as to exclude them from your final full text searches.
In my app , I am using phone numbers like +17896786788,+322657579849.
I would like to retrieve only the country code i.e, +1 or +322 by passing any phone number, that is I will send phone number and it will return the country code of that number.
Is there any API or anything available to get the country code from the phone number?
How can I find that?
I dont know about an API for splitting country code from a phone number,
But you can use this link to get all countries and their corresponding codes. Its a json file. You first parse all codes to an array from this json and then compare each element wth your phone number by using "range" funtion along with + symbol
Try it. U will get it.
I wanted to have a check whether the phone number getting from the contacts is a Mobile number or a fixed line(landline) number. I have tried using the regrex but all is in vain..any help will be highly appreciable
For filtering contact by mobile number and landline you need have list of std code in database and then you can check if immediate digits after country code match std code then it's landline. You can search for such api as well.
Try : http://www.searchbug.com/api/
A user enters his/her number of credit hours per course in my UITextField in this format....
4,3,4,3,3
(4 credit hours for 1st course, 3 credit hours for 2nd course, so on)
Conditions:
The user can only enter in MIN of 1 course and MAX 5 courses, the credit hours must be separated by a comma except for the last one, the string should contain only numbers and commas (no letters etc.) in that order.
I am trying to display an error message if conditions are violated. I think I will need to create a regExp. I am not sure how to create one since the user can enter in 2 courses so... (3,4) and still be okay. (like it cant follow a strict format like phone number).
Rather than letting the user enter what they think is correct and then telling them they're wrong at the end, consider implementing the text field delegate method textField:shouldChangeCharactersInRange:replacementString:. This doesn't preclude you using the regex, but you can also filter the characters typed by the user to prevent any letters and inform the user immediately when they make a mistake.