re = /^\s*\/\*.*?\*\//m
str = '/**
* base comment
* (c) SOMEBODY SOMETIME
* something
*/
///<!-- ------metadata-XML------- -->
/// <module type="javascript"> A
///<desc> some desc
/// </desc>
(function( a /* param A */) { // programmers comment ... enclosure
/*! user doc
this module ....
* reguired
.....
*/
var b={}; // programmers in line comment
// single line comments
// The cookie spec says up to 4k per cookie, so at ~50 bytes per entry
// that gives a maximum of around 80 items as a max value for this field
b.a=a;
var str = " tttt //this is not comment ! tttt "
var str2 = " tttt /* this is not comment too ! \\
.............. */ ttt ";
global.b = b;
}(global);
///</module>'
# 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