If we take the following patterns: 70000@.* and 970000@.* the string 970000@ILoveFishSticksAndTarTarSauce.com:5060 is returning a match to 70000@.*
I understand why it matches, but I need to modify the regex to only do a full string match.
Any ideas?
Thanks!
I am using the .Net 3.5 library
Here is the code:
[Microsoft.SqlServer.Server.SqlProcedure]
public static void RouteRegex(string phoneNumber, out string value)
{
if (string.IsNullOrEmpty(phoneNumber))
{
value = string.Empty;
return;
}
const string strCommand =
"Select RouteID,sequence,Pattern From SIPProxyConfiguration.dbo.Routes order by routeid, sequence asc";
using (var connection = new SqlConnection("context connection=true"))
{
try
{
connection.Open();
using (var command =new SqlCommand(strCommand,connection))
{
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var regEx = reader[2] as string;
if (string.IsNullOrEmpty(regEx)) continue;
var routeId = reader[0];
var sequence = reader[1];
var match = Regex.Match(phoneNumber, regEx);
Regex.IsMatch()
if (!match.Success) continue;
value = routeId.ToString();
return;
}
}
}
value = "No Match!";
}
catch (Exception ex)
{
value = ex.Message;
return;
}
}
}