re = /^\s*@(?<param>\S+)(?<dtwhitespace>\s*)\/\*##DATATYPE\((?>lhapp_owner\.)?(?<datatype>[^)]+)[^ ,]+(?<outparam>\s*OUT)?(?<comma>,?)(?<paramwhitespace>\s*)?(?<paramdoc>--##PARAM @.*)$/m
str = ' @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 '
subst = '\\t${param}${dtwhitespace}IN${outparam}\\t\\t${datatype}%TYPE${comma}${paramwhitespace}${paramdoc}'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html