$strOutput =~ s{ # First, we'll list things we want
# to match, but not throw away
(
(?: # Match RegExp
[\(=]\s* # start with ( or =
/ [^\r\n\*\/][^\r\n\/]* / # All RegExps start and end
# with slash, but first one
# must not be followed by *
# and cannot contain newline
# chars
#
# var re = /\*/;
# a = b.match (/x/);
)
| # -or-
[^"'/]+ # other stuff
| # -or-
(?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+ # double quoted string
| # -or-
(?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+ # single quoted constant
)
|
# or we'll match a comment. Since it's not in the
# $1 parentheses above, the comments will disappear
# when we use $1 as the replacement text.
/ # (all comments start with a slash)
(?:
\*[^*]*\*+(?:[^/*][^*]*\*+)*/ # traditional C comments
| # -or-
/[^\n]* # C++ //-style comments
)
}{$1}gsx;
####
$strOutput =~ s{ # First, we'll list things we want
# to match, but not throw away
(
# Match a regular expression (they start with ( or =).
# Then the have a slash, and end with a slash.
# The first slash must not be followed by * and cannot contain
# newline chars. eg: var "re = /\*/;" or "a = b.match (/x/);"
(?:
[\(=] \s*
/
(?:
# char class contents
\[ \^? ]? (?: [^]\\]+ | \\. )* ]
|
# escaped and regular chars (\/ and \.)
(?: [^[\\\/]+ | \\. )*
)*
/[gi]*
)
| # or other stuff
(?:
[^"'/]+
)
| # or double quoted string
(?:
"[^"\\]* (?:\\.[^"\\]*)*" [^"'/]*
)+
| # or single quoted constant
(?:
'[^'\\]* (?:\\.[^'\\]*)*' [^"'/]*
)+
)
|
# or we'll match a comment. Since it's not in the
# $1 parentheses above, the comments will disappear
# when we use $1 as the replacement text.
/ # (all comments start with a slash)
(?:
# traditional C comments
(?:
\* [^*]* \*+
(?: [^/*] [^*]* \*+ )*
/
)
| # or C++ //-style comments
(?:
/ [^\n]*
)
)
}{$1}gsx;
####
/*===========================================================================
' Subroutine: None
' Description: None.
'==========================================================================*/
function SimpleHTMLEncode (strHTMLToEncode) {
var strOutput = strHTMLToEncode;
if (! strOutput) {
return;
}
strOutput = strOutput.replace(/"/gi, """); // aka "
// strOutput = strOutput.replace(/&/gi, "&"); // aka &
strOutput = strOutput.replace(/'/gi, "'"); // blah
return (strOutput);
}
/*===========================================================================
' Subroutine: GetAddRolesArray
'==========================================================================*/
function GetAddRolesArray() {
return (BuildAddRolesObject (oRHS));
}
/*
This is a C-style comment
*/
// This is a comment.
function HelpMe () {
var regex = /big'fat/; // comment
var regex = /\\/; // comment
var reMatch = mystring.match(/asf'asfs/); // comment
var reMatch = mystring.match(/[/\\*?"<>\:~|]/gi); // comment
var reSearch = mystring.search(objRegex); // comment
var reSplit = mystring.split("\\"); // comment
}
/*
Test1
*/
####
function SimpleHTMLEncode (strHTMLToEncode) {
var strOutput = strHTMLToEncode;
if (! strOutput) {
return;
}
strOutput = strOutput.replace(/"/gi, """); // aka "
// strOutput = strOutput.replace(/&/gi, "&"); // aka &
strOutput = strOutput.replace(/'/gi, "'"); // blah
return (strOutput);
}
/*===========================================================================
' Subroutine: GetAddRolesArray
'==========================================================================*/
function GetAddRolesArray() {
return (BuildAddRolesObject (oRHS));
}
/*
This is a C-style comment
*/
// This is a comment.
function HelpMe () {
var regex = /big'fat/; // comment
var regex = /\\/; // comment
var reMatch = mystring.match(/asf'asfs/); // comment
var reMatch = mystring.match(/[/\\*?"<>\:~|]/gi);
var reSearch = mystring.search(objRegex);
var reSplit = mystring.split("\\");
}