Part Replace multiple words using Regex -
I want to process a lot of files as part of post migration of my code. The Migration Tool can handle Regx and we write something like the following:
'Change #' Column (",". Column ("
Replace All All Events") column ("with". Item ("."
One of our requirements as I tap string word I.e. I want to replace it with double quotation marks i.e. "optional" for example, byVal strID2 should be string = nullstraking
string - as the optional ByVal strID2 = ""
As NullString in VB6 is now going to be a square variable and in the function declaration it should be a constant.
So, I need RegEx with one of the following criteria:
- Make sure that in the function declaration it means "function" whose name is "bracket" and "cell" , Then any event of [= NullString] should be replaced with [= ""] until we hit the closing bracket) ", as the declaration may be on multiple lines. / Li>
- Just see that its optional parameters. Match the word "alternate" and then replace "Like string = NullString" and NullString with "".
I can use one of 2 as a criterion but I'm unable to write a RegEx below, I have a sample file and I have explained what I want for each line.
My Ramp File Content
Line 1 : Expected Output strong> For each line: Public Ceremony GetAllAddresses (ByVal lngObjectType string, as ByVal strID1 string, as optional ByVal strID2 string = NullString, as optional ByVal strID3 string = NullString, Optional ByVal blnExtraAddresses as Boolean form = false, optional ByRef objDataRequest CDataRequest = Nothing) as in ADORecordset
line 2 : string as a dot
Line 3 : s = NullString
line 4 ( Empty):
Line 5 : Public function getDefaultPaymentAddress (ByVal lngObjectType integer, ByVal strID1 string, ByVal as strID2 string, optional ByRef ObjDataRequest CDataRequest = nothing as in the form of typAddress
line 6 : public function myfunc (optional ByVal strID2 = string = NullStr, _
line 7 : & nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; ; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; Optional ByVal strID3 as string = NullString, _
line 8 : & nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; Boolean = false, _
line 9 as optional ByVal blnExtraAddresses: & nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; & Nbsp; ; Optional ByRef objDataRequest form CDataRequest = nothing) as a string
Line 10 : with some code Comment = NullString
if myVar = NullString
, but it should not be matched and changed. Thanks in advance for help.
Regards, Nick
All changes made with a regex possible is not.
You can try the following:
'Repeat this until, unless there are any more changes, search: (function + \ w + * \ ([^) ] *)? \ BNullString \ b: Replace $ 1 "" 'Use this multiline match for this one: ^ ([\ t] * \ w + * = *) NullString \ b Replace: $ 1 ""
Comments
Post a Comment