RESULTS:
Execution Time(sec.):
0.000016
Raw Match Pattern:
CREATE PROCEDURE (?:dbo\.|\[dbo\]\.)*\[*([a-zA-Z0-9_ -]+)\]*
C#.NET Code Example:
using System;
using System.Text.RegularExpressions;
namespace myapp
{
class Class1
{
static void Main(string[] args)
{
String sourcestring = "source string to match with pattern";
Regex re = new Regex(@"CREATE PROCEDURE (?:dbo\.|\[dbo\]\.)*\[*([a-zA-Z0-9_ -]+)\]*");
MatchCollection mc = re.Matches(sourcestring);
int mIdx=0;
foreach (Match m in mc)
{
for (int gIdx = 0; gIdx < m.Groups.Count; gIdx++)
{
Console.WriteLine("[{0}][{1}] = {2}", mIdx, re.GetGroupNames()[gIdx], m.Groups[gIdx].Value);
}
mIdx++;
}
}
}
}
$matches Array:
(
[0] => Array
(
[0] => CREATE PROCEDURE dbo.uspGetEmployeesTest2
[1] => CREATE PROCEDURE [dbo].[uspGetEmployeesTest2]
[2] => CREATE PROCEDURE [My Procedure]
)
[1] => Array
(
[0] => uspGetEmployeesTest2
[1] => uspGetEmployeesTest2
[2] => My Procedure
)
)