String.prototype.trim = function ()
{
// Use a regular expression will be on the front and rear spaces
// replace it with an empty string.
Return this.Replace (/ (^ / s *) | (/ s * $) / g, "");
}
// String with spaces
Var s = "Leading and trailing spaces";
// Show "Leading and Trailing Spaces (35)"
WINDOW.Alert (" S.Length ") ")
// Delete the front and rear spaces
s = S.trim ();
// Show "Leading and Trailing Spaces (27)"
WINDOW.Alert (" S.Length ") ")
How to replace @AAB_AA to @ AAB_AA_1 @ AAB_AA is variable. Just find the string of @, with the end of the non-alphanumeric and "_", and replace the content of this string "_ 1" string s = "AFAS @ AAB_AA 5"; console.writeline (regex.replace "(@ [0-9a-za-z_] )", "$ 1_1")); string s = "AFAS @ AAB_AA 5 @ AAB_AACCC"; if @AAB_AA is fixed. How to ensure that @AAB_AACCC is not replaced? Console.Writeline (regex.replace (@ AAB_AA ) ([^ 0-9A-ZA-Z _] "," $ 1_1 $ 2 "));