Regular Expressions. Q

Discussion in 'ASP .Net' started by Benjamin, Sep 21, 2004.

  1. Benjamin

    Benjamin Guest

    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, Sep 21, 2004
    #1
    1. Advertising

  2. Benjamin

    Karl Seguin Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
     
    Karl Seguin, Sep 21, 2004
    #2
    1. Advertising

  3. Benjamin

    Benjamin Guest

    Thanks,
    Benjamin

    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:#...
    > 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" <> wrote in message
    > news:...
    > > 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, Sep 22, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas

    Custom Regular Expressions in ASP.net

    Jay Douglas, Nov 2, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    614
    mikeb
    Nov 3, 2003
  2. mark

    Regular expressions

    mark, Jun 30, 2003, in forum: Perl
    Replies:
    4
    Views:
    1,730
  3. Dustin D.
    Replies:
    1
    Views:
    11,281
  4. Jay Douglas
    Replies:
    0
    Views:
    619
    Jay Douglas
    Aug 15, 2003
  5. Noman Shapiro
    Replies:
    0
    Views:
    240
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page