0

I need help to remove the string /* s */ (comments in .c and .h files) from some files using Ruby. Is it correct to use gsub to do this. I know that this string is always placed at the beginning av a line.

thx.

1 Answer 1

1
str.gsub(/^\/\*.*?\*\// , '')

Doesn't look nice, but should do it.

Sign up to request clarification or add additional context in comments.

1 Comment

Better use .*? instead of .* in there, otherwise you will remove everything between the start of the first comment and the end of the last comment within the string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.