String. Prototype. Trim = function ()
{
// Use a regular expression to separate spaces
// Replace it with a null string.
Return this. Replace (/(^/S *) | (/S * $)/g ,"");
}
// A string with spaces
VaR S = "Leading and trailing spaces ";
// Display "Leading and trailing spaces (35 )"
Window. Alert (S + "(" + S. Length + ")");
// Delete leading and trailing Spaces
S = S. Trim ();
// Display "Leading and trailing spaces (27 )"
Window. Alert (S + "(" + S. Length + ")");
How to replace @ aab_aa with @ aab_aa_1
@ Aab_aa is variable.
Is how to find the string starting with @, ending with a non-letter number and "_", and replace the content of the string with + "_ 1"
String S = "AFAS + @ aab_aa + 5 ";
Console. writeline (RegEx. Replace (S, "(@ [0-9a-za-z _] +)", "$1_1 "));
String S = "AFAS + @ aab_aa + 5 + @ aab_aaccc ";
Assume that @ aab_aa is fixed. How can I ensure that @ aab_aaccc is not replaced?
Console. writeline (RegEx. Replace (S, "(@ aab_aa +) ([^ 0-9a-za-z _] +)", "$1_1 $2 "));