I've the folllowing string and I want to split it:
"INSERT INTO test (test, test1, test2, test3) values (@test, @test1, @test2, @test3)";
The values that I want to get are the seperated @test @test1 @test2 @test3 So I can do something different with each one
This is what I currenly have so far.
string str = "INSERT INTO test (test, test1, test2, test3) values (@test, @test1, @test2, @test3)"
var pattern = @"(?<=@)[^@]*(?=>,)";
foreach (var m in System.Text.RegularExpressions.Regex.Split(str, pattern))
{
Console.WriteLine(m);
}
This returns the whole string:
INSERT INTO test (test, test1, test2, test3) values (@test, @test1, @test2, @test3)
I hope some of you can help me because it's the last pin for my program to work.
Regex.Matches(str, @"@\w+").Cast<Match>().Select(p => p.Value).ToList(). Although at this point, Kell's answer should work the same. Well, with the exception that the regex only matches word chars after@.