Hi i have a list of phone numbers that id like to send sms messages too but some of them are landlines and some are cell phone numbers is there a way to clean the list to tell which is which?
There are services that will identify whether or not a phone number is a wireless or landline number. When trying to determine whether a phone number is a wireless or a landline number you need to make sure number portability is taken into consideration. Regarding North American phone numbers, some services only look at the exchange block (the first 7 digits) of the phone number to see if the phone number is assigned to a wireless or a landline block. Since numbers can be ported (e.g. you can port your original landline number to a cell phone and vice versa) it's important to check the full 10 digit number to see whether it has been ported or not.
The company I work for, PacificEast, provides this in batch (you send the entire file) or via a web service (you query one phone number at a time) for US and Canadian phone numbers. Have a look at our Line Identification Append service. Other companies provide similar services as well. Our TeliSight service will also provide the email address format you can use to send an email that will be converted to an SMS message for those North American carriers that support it.
Related
There are very detailed regex expressions to identify Visa, MasterCard, Discover and other popular credit card numbers.
However, there are tons of other credit cards; termed popularly as Store Credit Cards (these are not the Visa or Amex powered cards). Examples of these cards are Amazon, GAP brands, Williams Sonoma, Macy's and so on. Most of these are Synchrony Bank Credit Cards.
Is there a regex to identify these different brand credit card numbers?
It's ludicrous to use a regex to identify the network. All it takes is a prefix matching at most.
A card number has 16 digits. The first few identify the network and the bank.
Some people would say that Visa starts with 4 and MasterCard starts with 5 but that's a broad approximation at best. You can have a look at your card, should be right most of the time.
It would be easy to figure out what a card is if one could get a registry of known prefixes, but there is no public registry to my knowledge. I highly doubt that any of the parties involved would like to publish that information.
The first eight digits (until recently this was six digits) of an international card number are known as the Issuer Identification Number (IIN) and the registry that maintains this index is the American Bankers Association
The list of IINs is updated monthly and spans tens of thousands of rows. Unfortunately a fixed Regex isn't going to be accurate for any length of time.
I have a form on my website and my customers send message to me with this form. Sometimes they write their credit card number on the message. So this is really critical. I want to mask these credit card numbers. But of course card numbers don't come on a regular basis.
Example 1: 1111222233334444
Example 2: 4444 3333 2222 1111
Example 3: 4444-3333-2222-1111
Example 4: 4444 - 3333 - 2222 - 1111
Example 5: 4444--3333--2222--1111
So I can mask for example 1, 2 and 3. But if there are more than one space or dash between numbers I can't.
And this is my last regex:
preg_replace("/(?:\b| )([3456]\d{3})([ -]+){0,1}\d{4}([ -]+){0,1}\d{4}([ -]+){0,1}(\d{0})/", "$1********$2", $a1);
And results for this regex:
Result 1: 4444********1111
Result 2: 4444******** 1111
Result 3: 4444********-1111
Result 4: 4444******** - 1111
Result 5: 4444********--1111
So what should I do in regex? Thanks.
May I suggest that you separate validation of your credit card number from the presentation of that number to your users via the UI? Assuming you have only stored valid credit card numbers, then it is probably safe to assume that every number has at least 8 digits. If so, then you can just use a blanket regex to only display the first 4 and last 8 digits:
$cc = "4444--3333--2222--1111";
echo preg_replace("/(\d{4}).*(\d{4})/", "$1********$2", $cc);
4444********1111
Demo
You might point out that this puts the same number of stars in between every card number. But, then again, this is a good thing, because it makes it even harder for a snooper to fish out what the real unmasked number actually is.
Edit:
Here is a smarter regex which will star out the middle portion of any number, leaving only the first and last 4 characters visible:
$cc = "4444--3333--2222--1111";
echo preg_replace("/(?<=.{4}).(?=.{4})/", "*", $cc);
4444**************1111
Note that this solution would not remove anything from 11114444 as a theoretical input.
How to mask credit card number mask in a text [with regex]?
Don't.
Sometimes they write their credit card number on the message.
They really shouldn't. Don't encourage this behavior. It is not PCI compliant:
What is PCI Compliance?
The Payment Card Industry Data Security Standard (PCI DSS) applies to companies of any size that accept credit card payments. If your company intends to accept card payment, and store, process and transmit cardholder data, you need to host your data securely with a PCI compliant hosting provider.
When you accept credit card data via a website, do so using an approved service provider like Stripe, PayPal, BlueSnap, SecurionPay, etc. These services are immensely popular not because it's hard to make payment systems, but because they're hard to make right (and legal). They all have PHP API's, so you can have people enter credit card data that you never see, and still charge them for amounts that you agree upon.
For example, if you were using Stripe and you wish to inform your customer what credit card they signed up with, their card object has a last4 property that gives the last four digits of the card: At this point you never knew the full credit card number, and you didn't even have to consider whether giving the first four and the last four was a security violation.
Further guidelines:
Never store electronic track data or the card security number in any form
While you may have a business reason for storing credit card information, processing regulations specifically forbid the storage of a card’s security code or any “track data” contained in the magnetic strip on the back of a credit card.
The card security number, called by many acronyms including CVV2, CID, and CSC, is the three digit number on the back of Visa/MasterCard/Discover cards or the 4 digit number on the front of American Express cards. It is designed to provide a way for merchants to know whether a customer authorizing a transaction over the phone or via the Internet actually has the card in their possession. This approach only works if the security code is never stored with the card number. Electronic storage makes this easy. You simply do not create a field for the security code. For paper storage, you need to redact (cross out with a dark pen to make unreadable) the security code after you successfully process the transaction and before you store a paper authorization form. [...]
Clearly you should store neither security codes nor track data purposely. But, you need to make sure you don’t store it inadvertently as well. To do this, be certain to use only approved hardware and software. [...]
Make sure all electronic storage of credit card account numbers is encrypted and all paper storage is secured
[...] Electronic storage of credit card numbers is also common if, for example, you process recurring or repeat transactions. If you do this, you need to make certain that you never store these files unencrypted. You need to make certain that any electronic storage is encrypted using a robust encryption algorithm. That way, if your computer is stolen or if someone in your office gains unauthorized access, you have some level of protection for the credit card numbers.
There are many service providers that offer secure storage—either as a standalone service or as part of a payment processing package. These services typically provide you with a “Token” for a card number they store. You can store the token in any unsecured file. When you’re ready to process a payment, you simply send the service provider the token and it retrieves the full card number for the sole purpose of processing the payment. (It’s technically more complicated than that, but you get the idea.) Just be certain to use a PCI DSS Verified provider [...]
Check the next regex \b([3-6]\d{3})(?: *-* *\d{4}){2} *-* *(\d{4})\b.
When I set the Caller ID Name and make a RingOut through the RingCentral Java API, the receiving number displays only my Main Number, not my Caller ID Name. How do I get the call to show the CNAM?
Full disclosure, I am the COO of Telo, the makers of OpenCNAM and EveryoneAPI.
I wanted to clarify a few things contained in the initial answer to this question. I have had to answer the questions as my rep power on Stack Overflow limits my ability to post this as a comment to the question. :/
First is a quick overview of network CNAM. Next, a brief explanation of how it works and the caveats. After that, there are some specifics around Telo products, which some folks may find of value.
Overview of Network CNAM
In the +1 dialing plan (NANP) there are over 20 databases that store CNAM values, or caller name, on behalf of the telephone carriers. In practice, about 12 of them are actually queried by CNAM providers. The terminating carrier (the carrier receiving the call) queries their CNAM provider milliseconds after receiving the call with the CID (telephone number). While the call is being set up to ring, the CNAM provider will return the name value associated with that telephone number so that it can be delivered with the telephone call.
How This Works
If network CNAM is being delivered -- meaning, the carrier-supplied values that are being stored by the carrier's storage provider -- then the CNAM provider will route the query to the appropriate storage provider based on the telephone number. If a number has been ported, then the NPAC will contain the information needed to resolve the number to the appropriate storage source to be queried. If there is no record in the NPAC, then the CNARG will contain the information needed to match the telephone number to the carrier, and thus the correct storage provider.
Caveats
The match-rate for useful name values in the traditional CNAM network is about 50%. This is due to the fact that not all carriers participate. For example, while it is easy to set up CNAM values for AT&T Wireless, T-Mobile, and Sprint, Verizon Wireless is 'opt-in' and is not automatically supported. There are other carriers that do not participate in the CNAM network, and still, other VoIP providers that do not update CNAM values. The traditional CNAM network also does not provide values for toll-free numbers, and only has coverage inside of the +1 dialing plan.
About OpenCNAM
While OpenCNAM provides network CNAM through its Standard service level, it also provides two service levels that address the limitations of network CNAM mentioned above. The Plus service level is optimized for coverage, match-rate, and accuracy, while the Value service level provides excellent coverage and match-rates, but is optimized for cost. You can find out more about the service levels here.
EveryoneAPI For Current Carrier and Linetype
Our other product, EveryoneAPI, provides the most accurate data around linetype (landline or mobile) and current carrier, which will include ported numbers. The coverage for these data-points is global and the match-rate is nearly 100%. While the numverify looks very useful, it is providing what is known as LERG data for the +1 dialing plan, from what I can tell. This will not accurately reflect carrier information for ported telephone numbers.
CNAM Overview and Limitations
CNAM / Caller ID Name support is dependent on the the type of numbers used by the calling and receiving (callee) parties.
Caller must be using a local landline number, otherwise the phone number will be displayed.
Receiver must be using a non-mobile number, otherwise the phone number will be displayed.
I validated this by calling two numbers, a mobile number that showed only the phone number and a landline number that showed the CNAM.
You can read more on CNAM in this Knowlegebase Article:
Outbound Caller ID Name Overview and Frequently Asked Questions
This mentions the following excerpts:
The Outbound Caller ID Number must be a local landline number.
Toll free numbers are not supported. When the Outbound Caller ID is set to a Toll Free number, only the number will display.
Mobile numbers do not support CNAM. If the receiving party is a Mobile number, only the number will display.
When the Outbound Caller ID is set to Blocked, the call recipient will see UNKNOWN or ANONYMOUS as the Caller ID/Caller Name.
Checking Receiving Line Type
Given that mobile numbers don't support CNAM, it's useful to see if the number you are calling is a mobile number of not. You can verify the type of number you are calling by using the numverify API (https://numverify.com/). You can also use this CLI app and Go SDK grokify/numverify. Look for the line_type property in the validate API response which can be mobile or landline.
For example (phone number changed):
{
"valid": true,
"number": "16505550100",
"local_format": "6505550100",
"international_format": "+16505550100",
"country_prefix": "+1",
"country_code": "US",
"country_name": "United States of America",
"location": "Redwood Cy",
"carrier": "AT\u0026T Mobility LLC",
"line_type": "mobile"
}
Checking the CNAM Database
Receiving systems have their own CNAM databases, but you can check to see if your name has propagated by calling a CNAM database API, such as the one provided by OpenCNAM (https://www.opencnam.com/). Here is an example call for OpenCNAM. Adding the format query parameter is very important as the API will retry an empty body without it.
curl -XGET 'https://api.opencnam.com/v3/phone/+16505550100?format=json&account_sid=<myAccountSID>&auth_token=<myAuthToken>
You will receive a response like:
{
"name": "My Caller ID Name",
"number": "+16505550100",
"price": 0.0039,
"uri": "/v3/phone/+16505550100"
}
I need to find the handset model using IMEI number... There are some websites which provide this information for one or two IMEI in a day but I want some DB or webservice or API through which I can know the model of the phone using IMEI in bulk.. I have around 65000 IMEI number for which I want to know the model information and have to insert them in my DB.. Thanks in advance for your help..
What you really need is a Type Allocation Code (TAC) reference. The TAC is the first eight digits of the IMEI number and uniquely identifies the device. The other digits are the serial number (and version and check digit info).
However, there is not a publicly available database of TAC codes. New TAC codes come out almost daily, as new devices are registered and as new codes are issued for existing devices (for example, there are over 100 TAC codes for an especially popular device). You can only get a complete list if you are affiliated with a wireless carrier or a manufacturer. The codes are considered proprietary.
I have been tasked to "verify" the length of a U.S. Banking Institution ACCOUNT NUMBER for a web app I'm developing. I cannot find anything through SOF, Google, Fed reserve etc that outlines an account number standard length that we have in the United States. For the record I believe this is futile.
If someone could point me to any official documentation on the web, or has an example regular expression, or knows if there is a standard that exists, I would appreciate it greatly.
ADDED:
What would interest me even more since the response is overwhelming that their is no standard....has anyone ever run into a bank account number that is not completely "numeric"\
ADDED:
Thanks to everyone and their responses. Due to having no standard in the US, we are not going to enforce a length check, and we are going to store the number as a varchar due to the fact that it may be possible that a bank may assign alpha characters in their account numbers. Seems 99.999999% unrealistic in our view, but no standard means we will accept alpha characters and run the check on the account number to verify if it works or not. Thanks again all!
There is no standard for US banks' account numbers.
IBAN is not used in the US.
There is a limit for ACH transactions (4-17 digits), but not all transactions have to be ACH.
And yes, the US banking system is antiquated.
I'm looking at a DW (Data Warehouse) of 38 different systems at a bank and the length of account varies widely depending on the product. Several of the systems have alphabetic characters in the account numbers. This is probably irrelevant since they are special types of customer accounts like brokerage accounts and other things which aren't accessible through ACH - you need to specify what kind of account you're interested in. If you restrict yourself to accounts which you can get to through ACH, you can simply restrict to numeric digits.
You can get a lot more information about ACH at: http://www.nacha.org/
Good luck with that, because you can't.
Banks are free to use just about anything as an account number. I think the only validation you can do is whether or not they're numeric (as they all are).
The most common length for bank account numbers is 9, 12, or 10 digits. Although they range from 4 to 17 digits long. I have a large database of valid numbers and there's no pattern that I can see to the "account number".
A "routing number" defines the bank (pretty much) but even within a particular routing number, the account numbers can be of different lengths.
This is why payroll services often require an extra day (or two) before initiating Direct Deposit in order to "prenote" the account (validate it by performing a no-op ACH transaction) because you really can't verify it otherwise.
You can validate the routing number (or ABA) by downloading the DB (fixed field width text format) from the federal reserve bank. The data is here:
https://www.frbservices.org/EPaymentsDirectory/fpddir.txt and the layout describing the data is here:
https://www.frbservices.org/EPaymentsDirectory/fedwireFormat.html
There are companies (lyonslive.com) that offer a webservice to validate account numbers but they charge per validation (volume based pricing starting # 60 cents per check - if volume is high enough it can be as low as 24 cents).
Don't you mean International Bank Account Number? If yes, this is a regex for IBAN (all IBANs):
[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}
UPDATE: Actually, according to Wikipedia: Banks in the United States do not provide IBAN format account numbers. Any adoption of the IBAN standard by U.S. banks would likely be initiated by ANSI ASC X9, the U.S. financial services standards development organization but to date it has not done so. Hence payments to U.S. bank accounts from outside the U.S. are prone to errors of routing.
In Addition to the other great answers here, i think its helpful to know that routing numbers in the United States include a checksum digit which can be helpful for quick validation that the user typed it in correctly
http://www.brainjar.com/js/validation/
basically all US routing numbers should pass the following test:
3 * (digits[0] + digits[3] + digits[6]) +
7 * (digits[1] + digits[4] + digits[7]) +
(digits[2] + digits[5] + digits[8]) % 10 === 0
Very interesting. It seems like all routing/transit numbers are 9 digits.
I just checked American Express's online bill pay, for bank accounts they limit their field to 15 numerics. Chase limits theirs to 17. I would probably continue checking and maybe start to call a few banks to find out what their specifications are. It doesn't seem like there is a standard.
Another potential way to determine the length would be to ask the company that performs the transaction. Where does the account number get used? They should have specifications on what they will accept.
I don't think there is a standard - different institutions seem to use different lengths of account number. There probably is an upper limit - it is unlikely to be less than 20.
There is no standard for a bank account number in the US. There is a standard for the routing number, because that's shared between banks; the account number, however, is only of use internally by the bank itself.