TRIM ()

xiaoxiao2021-03-06  62

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 ") ")

转载请注明原文地址:https://www.9cbs.com/read-112583.html

New Post(0)