Jump to content

Regular Expression for Code Conversion


 Share

Recommended Posts

I am looking to writing an automation script for converting the following SQL procedure code into VBCode as shown below

Example

 

ALTER PROCEDURE [dbo].[firstprocedure]

(

       @var1 varchar(10),

       @var2 varchar(7),

       @var3 float

)

 

 CONVERSION

Public Function firstprocedure(ByVal var1 As String, ByVal var2 As String, ByVal var3 As Integer) As DataSet



        Dim ds As New DataSet()

        '**************query  with stored procedure**********

        Dim CMD As New SqlCommand("GetCountOfTempGramWtsGwByFoodCodeProgressAndNewSequence")

        CMD.Connection = GetConnection()

        CMD.Parameters.Add("@var1", SqlDbType.VarChar).Value = var1

        CMD.Parameters.Add("@var2", SqlDbType.VarChar).Value = var2

        CMD.Parameters.Add("@var3", SqlDbType.Float).Value = var3

        CMD.CommandType = CommandType.StoredProcedure

        Dim adapter As New SqlDataAdapter(CMD)

 

 

I will be reading the procedural code from the first file that has to be read and create the VB code by writing onto a new file.

My approach is that I need the following information captured in Variables which I can insert later onto the new file as and where applicable.

 

In order to do that I need to extract the following bit of information from the file to be READ

Name of procedure : firstprocedure

List of Variables : @var1, @var2, @var3  

Data Types: varchar, varchar & float

 

What I need help with is extracting the list of variables and data types in separate variables.

I am looking to build a Regular Expression which I can use to achieve the same. 

I tried making use of StringSplit function delimited on spaces(" ") but that did not work when reading the file from notepad. I reckon it does not detect spaces in the file.

Please help me with the RegExp.

Any other suggestions on how best to go about doing this conversion are also welcome.

Thank You

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...