Regular Expressions. Q

B

Benjamin

I have string with data as follows.



myString = "~delete from t1~Delete from t2~Update t3 set c1='8'"

When I process this string I would like to get all these SQL statements one
at a time.

I know I can do this using string manipulation.

Is there any easy and efficient way to do these using regular expressions? I
am exploring Regular Expressions!!!

Thanks,

Benjamin
 
K

Karl Seguin

Benjamin, try:

Regex re = new Regex(@"(~(?<capture>[^\~]*))", RegexOptions.ExplicitCapture
| RegexOptions.Compiled);
MatchCollection mc = re.Matches("~delete from t1~Delete from t2~Update t3
set c1='8'");
for (int i = 0; i < mc.Count; ++i) {
Match m = mc;
string value = m.Groups[1].Value;
}

Karl
 
B

Benjamin

Thanks,
Benjamin

Karl Seguin said:
Benjamin, try:

Regex re = new Regex(@"(~(?<capture>[^\~]*))", RegexOptions.ExplicitCapture
| RegexOptions.Compiled);
MatchCollection mc = re.Matches("~delete from t1~Delete from t2~Update t3
set c1='8'");
for (int i = 0; i < mc.Count; ++i) {
Match m = mc;
string value = m.Groups[1].Value;
}

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Benjamin said:
I have string with data as follows.



myString = "~delete from t1~Delete from t2~Update t3 set c1='8'"

When I process this string I would like to get all these SQL statements one
at a time.

I know I can do this using string manipulation.

Is there any easy and efficient way to do these using regular
expressions?
I
am exploring Regular Expressions!!!

Thanks,

Benjamin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top