|
#1
|
|||
|
|||
Passing regex match to a script function
In a Replace Files step, I need to pass the result of a regex match. Basically, I need to match a filename in a file using the following regex:
Code:
^.*"OutputFilename"\s*=\s*"(.*)".*$ Code:
[GetFileNamePart($1)] |
#2
|
|||
|
|||
Unfortunately you can't do exactly what you are wanting (pass a matched expression to script), but you can accomplish what you are trying to do with just a regular expression.
Below is an example Replace In File step that uses a different regular expression that does what I think you are trying to do. <step action='Replace in File' type='0'> <FileIn>c:\temp\test.txt</FileIn> <FileOut>c:\temp\output.txt</FileOut> <Find>(^[[^\n"]]*"OutputFilename"\s*=\s*)"(([[^\n\\"]]*\\)*)([[^"\n]]*)[["\n]]</Find> <Replace>$1"(?3$4)"</Replace> <indent type='3'>1</indent> <name>Replace Full Path with filename only</name> </step> Note: Please note that using .* is not a very safe thing to do with regular expressions in Visual Build Pro because it doesn't function in a 'line mode'. .* is greedy in Visual Build Pro which can consume line feeds. The sample regular expression above adheres to the advice in the help file for Replace In File Action using [^\n]* instead of .*. Note 2: Just copy the above xml fragment and paste into Visual Build Pro. A Replace In File step will be created for you to review/use. Last edited by kevina; 09-29-2004 at 12:05 PM. |
|
|