re = /type\s([_A-Za-z]+)\s*=\s*(function|procedure)(.*?cdecl;)\s*var(\s[_A-Za-z]+):\s*([_A-Za-z]+)\s(external.*?;)/
str = '
// It\'s better to create the object with the right prototype from the start.
type TJS_SetPrototype = function (cx: PJSContext; var obj: PJSObject;
var proto: PJSObject):Boolean; cdecl;
var JS_SetPrototype: TJS_SetPrototype external SpiderMonkeyLib name \'SM_SetPrototype\';
/// Write access an object\'s reserved slots
type TJS_SetReservedSlot = procedure (obj: PJSObject; index: uint32;
var v: jsval); cdecl;
var JS_SetReservedSlot: TJS_SetReservedSlot external SpiderMonkeyLib name \'SM_SetReservedSlot\';
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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