Regular expressions question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carlos Guzmán Álvarez

    #1

    Regular expressions question

    Hello:


    I want to know if it's possible to obtain the SQL commands stored on a
    string using as delimiter a ; character using Regular expressions (i
    have tryed it for some time without any result :)),anything like this
    (but supporting any combination of SQL commands ;)):

    "INSERT INTO TESTTABLE VALUES ( 'This is a semi-colon ;' );" +
    "INSERT INTO TESTTABLE VALUES ( 'This is not a semi-colon !' )"

    Giving as result:

    INSERT INTO TESTTABLE VALUES ( 'This is a semi-colon ;' )
    "INSERT INTO TESTTABLE VALUES ( 'This is not a semi-colon !' )



    Is this possible using Regular expressions




    --
    Best regards

    Carlos Guzmán Álvarez
    Vigo-Spain

  • Brian Davis

    #2
    Re: Regular expressions question


    Instead of using Split, you could use the Regex.Matches method with the
    following expression:

    [^';]+('[^']*')?[^';]*(?=;)


    If you need to use Split, this expression seems to work (although you should
    test it thouroughly):

    (?n)(?<=(^|;)[^']*('[^']*')?[^']*);



    Brian Davis



    "Carlos Guzmán Álvarez" <carlosga@telef onica.net> wrote in message
    news:e8pm2fudDH A.3448@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hello:
    >
    >
    > I want to know if it's possible to obtain the SQL commands stored on a
    > string using as delimiter a ; character using Regular expressions (i
    > have tryed it for some time without any result :)),anything like this
    > (but supporting any combination of SQL commands ;)):
    >
    > "INSERT INTO TESTTABLE VALUES ( 'This is a semi-colon ;' );" +
    > "INSERT INTO TESTTABLE VALUES ( 'This is not a semi-colon !' )"
    >
    > Giving as result:
    >
    > INSERT INTO TESTTABLE VALUES ( 'This is a semi-colon ;' )
    > "INSERT INTO TESTTABLE VALUES ( 'This is not a semi-colon !' )
    >
    >
    >
    > Is this possible using Regular expressions
    >
    >
    >
    >
    > --
    > Best regards
    >
    > Carlos Guzmán Álvarez
    > Vigo-Spain
    >[/color]


    Comment

    Working...