This should support many languages, including bash, which does not support \s :
help::[\r\n\t\f ]*(.*?)[\r\n\t\f ]*?(?:\*\/|-->)
You can also use one that prevents any unnecessary choices that make it easier to use. :
help::[\r\n\t\f ]*(.*?)(?=[\r\n\t\f ]*?\*\/|[\r\n\t\f ]*?-->)
You can use this as a funky .replace , but this can lead to fancy behavior:
/\/\*[\r\n\t\f ]*help::|<!--[\r\n\t\f ]*help::|[\r\n\t\f ]\*\/|[\r\n\t\f ]*-->/g
Explanation
Solution 1:
help:: Matches the text "help::" [\r\n\t\f ]* Matches any whitespace character 0-unlimited times (.*?) Captures the text [\r\n\t\f ]*? Matches all whitespace (?: Start of non-capture group \*\/ Matches "*/" | OR --> Matches "-->" ) End non capture group
[\r\n\t\f ]
\r Carriage return \n Newline \t Tab \f Formfeed Space
Solution 2 (supports almost everything)
help:: Matches "help::" [\r\n\t\f ]* Matches all whitespace 0-unlimited (.*?) Captures all text until... (?= Start positive lookahead [\r\n\t\f ]*? Match whitespace 0-unlimited \*\/ Matches "*/" | OR [\r\n\t\f ]*? Match whitespace 0-unlimited --> Matches "-->" )
Downgoat
source share