Regular Expressions. Q

  • Thread starter Thread starter Benjamin
  • Start date Start date
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
 
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
 
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

Similar Threads

Regular Expression 1
QueryString in SQL 3
Regular Expression for URL 4
regular expression 1
Regular Expressions........ 4
regular expression question 3
Regular expressions 20
Help With Regular Expression 2

Back
Top