Strip block comments: Difference between revisions
Content added Content deleted
(jq) |
|||
Line 866: | Line 866: | ||
}</lang> |
}</lang> |
||
=={{header|jq}}== |
|||
''Note: A version of jq with <tt>gsub/3</tt> is required to compile the function defined in this section.'' |
|||
The filter <tt>strip_block_comments/2</tt> as defined here does not attempt to recognize comments-within-comments. |
|||
<lang jq>def strip_block_comments(open; close): |
|||
def deregex: |
|||
reduce ("\\\\", "\\*", "\\^", "\\?", "\\+", "\\.", |
|||
"\\!", "\\{", "\\}", "\\[", "\\]", "\\$", "\\|" ) as $c |
|||
(.; gsub($c; $c)); |
|||
# "?" => reluctant, "m" => multiline |
|||
gsub( (open|deregex) + ".*?" + (close|deregex); ""; "m") ; |
|||
strip_block_comments("/*"; "*/")</lang> |
|||
'''Invocation''': |
|||
$ jq -s -R -r -f Strip_block_comments.jq sample_text_for_stripping.txt |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
<lang lb>global CRLF$ |
<lang lb>global CRLF$ |