Click or drag to resize
ZenophSMSextractPhoneNumbers Method (String)
Searches and extracts phone numbers from specified System.String input source.

Namespace: Zenoph.SMSLib
Assembly: Zenoph.SMSLib (in Zenoph.SMSLib.dll) Version: 2015.9.30.0 (2015.09.30.0)
public List<string> extractPhoneNumbers(
	string source


Type: SystemString
The source from where phone numbers should be searched and extracted.

Return Value

Type: ListString
Returns valid phone numbers found in the specified source.
Exception Thrown if the source is null, empty, or when user authentication has not been performed for settings to be loaded.

The method searches through source and extracts valid phone numbers into a list of System.String object. The returned phone numbers are those that are valid for user routes. Therefore, a phone number may be valid and exist in source but if it is not allowed on user routes, it will not be included.

source must be System.String object. For file sources, the contents of the file must loaded into a System.String object and specified as source for the method call.

The method requires user authentication before being called otherwise Exception will be thrown.

// Initialise SMS object and perform authentication
ZenophSMS sms = new ZenophSMS();

// example source containing phone numbers
string str = "Mr. ABC, XYZ Street, Kumasi, Tel: 233240111111;  Mr. EFG, AY Avenue, Kumasi, Tel: 0208999999;";

// The following method call will return the phone numbers 233240111111, 233208999999 into
// the variable nums, assuming that the default dial code is +233 (for 0208999999 to 233208999999).
List<string> nums = sms.extractPhoneNumbers(str);

// add the phone numbers.
foreach (string phonenum in nums)
    sms.addRecipient(phonenum, true);  // ignore throwing of Exception when the phone number is invalid.
See Also