pub fn extract(value: &str) -> IResult<&str, &str> {
	let (mut result, start) = if let Some(index) = consts::VALID_START_CHAR.find(&value) {
		(&value[index.start() ..], index.start())
	}
	else {
		return Err(nom::Err::Error(make_error(value, ErrorKind::RegexpMatch)))
	};

	if let Some(trailing) = consts::UNWANTED_END_CHARS.find(result) {
		result = &result[.. trailing.start()];
	}

	if let Some(extra) = consts::SECOND_NUMBER_START.find(result) {
		result = &result[.. extra.start()];
	}

	if result.is_empty() {
		return Err(nom::Err::Error(make_error(value, ErrorKind::RegexpMatch)))
	}
	else {
		Ok((&value[start + result.len() ..], result))
	}
}
/// Attempts to extract a possible number from the string passed in. This
/// currently strips all leading characters that cannot be used to start a
/// phone number. Characters that can be used to start a phone number are
/// defined in the `VALID_START_CHAR` regex. If none of these characters are
/// found in the number passed in, an empty string is returned. This function
/// also attempts to strip off any alternative extensions or endings if two or
/// more are present, such as in the case of: (530) 583-6985 x302/x2303. The
/// second extension here makes this actually two phone numbers, (530) 583-6985
/// x302 and (530) 583-6985 x2303. We remove the second extension so that the
/// first number is parsed correctly.
Attempts to extract a possible number from the string passed in. This
currently strips all leading characters that cannot be used to start a
phone number. Characters that can be used to start a phone number are
defined in the `VALID_START_CHAR` regex. If none of these characters are
found in the number passed in, an empty string is returned. This function
also attempts to strip off any alternative extensions or endings if two or
more are present, such as in the case of: (530) 583-6985 x302/x2303.
Attempts to extract a possible number from the string passed in . This currently strips all leading characters that cannot be used to start a phone number . Characters that can be used to start a phone number are defined in the ` VALID_START_CHAR ` regex . If none of these characters are found in the number passed in an empty string is returned . This function also attempts to strip off any alternative extensions or endings if two or more are present such as in the case of : ( 530 ) 583 - 6985 x302 / x2303 .
pub fn extract(value: &str) -> IResult<&str, &str> {
	let (mut result, start) = if let Some(index) = consts::VALID_START_CHAR.find(&value) {
		(&value[index.start() ..], index.start())
	}
	else {
		return Err(nom::Err::Error(make_error(value, ErrorKind::RegexpMatch)))
	};
	if let Some(trailing) = consts::UNWANTED_END_CHARS.find(result) {
		result = &result[.. trailing.start()];
	}
	if let Some(extra) = consts::SECOND_NUMBER_START.find(result) {
		result = &result[.. extra.start()];
	}
	if result.is_empty() {
		return Err(nom::Err::Error(make_error(value, ErrorKind::RegexpMatch)))
	}
	else {
		Ok((&value[start + result.len() ..], result))
	}
}
pub fn extract ( value : & str ) -> IResult < & str , & str > { let ( mut result , start ) = if let Some ( index ) = consts :: VALID_START_CHAR . find ( & value ) { ( & value [ index . start ( ) .. ] , index . start ( ) ) } else { return Err ( nom :: Err :: Error ( make_error ( value , ErrorKind :: RegexpMatch ) ) ) } ; if let Some ( trailing ) = consts :: UNWANTED_END_CHARS . find ( result ) { result = & result [ .. trailing . start ( ) ] ; } if let Some ( extra ) = consts :: SECOND_NUMBER_START . find ( result ) { result = & result [ .. extra . start ( ) ] ; } if result . is_empty ( ) { return Err ( nom :: Err :: Error ( make_error ( value , ErrorKind :: RegexpMatch ) ) ) } else { Ok ( ( & value [ start + result . len ( ) .. ] , result ) ) } }
Attempts to extract a possible number from the string passed in.
Attempts to extract a possible number from the string passed in .
value
&str