And i want just the blahblah bit, not any comments if there are any.
Any ideas on how to do this using a single regex would be most welcome,
I know I'm pushing my luck
And i want just the blahblah bit, not any comments if there are any.
Any ideas on how to do this using a single regex would be most welcome,
I know I'm pushing my luck
You're best off doing this the other way around (untested):
str.gsub(/\/\*.*?\*\//m, '')
That way you're stripping the comments out of the string, rather than trying to find bits of the string that happen not to be in comments. I'm not sure it's possible to simply do the latter, but I'm sure someone will be along in a few moments to prove me wrong
And i want just the blahblah bit, not any comments ...
Script starts
#!/bin/sh
ruby -wnle 'puts %r{^(.*?)(\s*/\*.*\*/\s*)?$}.match($_).captures[0]' <<EOF
Mary /* a girl */
had a
little /* but no less valuable */
lamb
EOF
<<< Script ends