using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^\s*@(?<param>\S+)(?<dtwhitespace>\s*)\/\*##DATATYPE\((?>lhapp_owner\.)?(?<datatype>[^)]+)[^ ,]+(?<outparam>\s*OUT)?(?<comma>,?)(?<paramwhitespace>\s*)?(?<paramdoc>--##PARAM @.*)$";
string substitution = @"\t${param}${dtwhitespace}IN${outparam}\t\t${datatype}%TYPE${comma}${paramwhitespace}${paramdoc}";
string input = @" @nInventoryPackID /*##DATATYPE(inventorypack.inventorypackid)<*/INT/*>##*/, --##PARAM @nInventoryPackID The ID of the inventory pack to be reclassifyed
@sInventoryPackNo /*##DATATYPE(inventorypack.inventorypackno)<*/NVARCHAR(254)/*>##*/, --##PARAM @sInventoryPackNo The inventory pack number to be reclassifyed (for logging)
@nQuantity /*##DATATYPE(inventorypack.quantity)<*/FLOAT/*>##*/, --##PARAM @nQuantity Quantity on the original pack
@nNewPartID /*##DATATYPE(inventorypack.partid)<*/INT/*>##*/, --##PARAM @nNewPartID ID of th epart associated with the new pack
@sNewInventoryPackNo /*##DATATYPE(inventorypack.inventorypackno)<*/NVARCHAR(254)/*>##*/, --##PARAM @sreclassifyInventoryPackNo The new reclassifyed inventory pack number
@nNewInventoryStateID /*##DATATYPE(invstate.invstateid)<*/SMALLINT/*>##*/, --##PARAM @nreclassifyInventoryStateID The state of the new pack
@nNewLocationID /*##DATATYPE(inventorypack.locationid)<*/INT/*>##*/, --##PARAM @nNewLocationID The location of the reclassified pack
@sFIFONumber /*##DATATYPE(inventorypack.fifonumber)<*/NVARCHAR(254)/*>##*/, --##PARAM @sFIFONumber the fifo number
@nLabelRequired /*##DATATYPE(settingsdatatype.datatypetinyint)<*/TINYINT/*>##*/, --##PARAM @nLabelRequired flag to indicate if a label is required to be printed
@nPrinterID /*##DATATYPE(lkmachinestageprinter.printerid)<*/TINYINT/*>##*/, --##PARAM @nPrinterID ID of the printer for a label
@nNewQuantity /*##DATATYPE(inventorypack.quantity)<*/FLOAT/*>##*/, --##PARAM @nNewQuantity Quantity on the new pack
@sComments /*##DATATYPE(comments.comments)<*/NVARCHAR(2000)/*>##*/, --##PARAM @sComments any comments for the new pack
@dOpenedDT /*##DATATYPE(inventorypack_.openeddt)<*/DATETIMEOFFSET/*>##*/, --##PARAM @dOpenedDT DATETIMEOFFSET the form was opened
@dModifiedDT /*##DATATYPE(settingsdatatype.datatypetimestamp)<*/DATETIMEOFFSET/*>##*/, --##PARAM @dModifiedDT The current plant date/time
@nLoginID /*##DATATYPE(lhapp_owner.auditlog.loginid)<*/SMALLINT/*>##*/, --##PARAM @nLoginID The loginID of the user logged on causing this call (1 if via Udi)
@nSessionID /*##DATATYPE(lhapp_owner.auditlog.lhsessionid)<*/INT/*>##*/, --##PARAM @nSessionID The IE session ID of the user's log on
@nPlantID /*##DATATYPE(lhapp_owner.auditlog.plantid)<*/SMALLINT/*>##*/, --##PARAM @nPlantID The plant ID (used for filtering the audit)
@nLangID /*##DATATYPE(lhapp_owner.login.rflanguageid)<*/SMALLINT/*>##*/, --##PARAM @nLangID The language ID to report any errors in
@nEntityTransactionLogID /*##DATATYPE(entitytransactionlog.entitytransactionlogid)<*/INT/*>##*/ OUT, --##PARAM @nEntityTransactionLogID The ID of the created entitytransactionlog entry
@nParentEntityTransactionLogID /*##DATATYPE(entitytransactionlog.entitytransactionlogid)<*/INT/*>##*/ --##PARAM @nParentEntityTransactionLogID The ID of the entitytransactionlogs parent ";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx