Javascript string extension library code

Source: Internet
Author: User

The string processing functions of JavaScript native are not rich enough,
Native string function: http://www.jb51.net/w3school/js/jsref_obj_string.htm

Question 1: Is there any extension library for the string type?
Yes, not many, not comprehensive.

Opinion 2: jquery is powerful in Dom operations, so we do not want the JS string extension library to be developed based on jquery. Do you agree?

Question 3: What string extension functions do we need?
For this problem, refer to other JS libraries and string operation functions in other languages.

Extended string type by prototype. JS:
Http://api.prototypejs.org/language/string/

String functions in other languages
C #:Http://msdn.microsoft.com/zh-cn/library/system.string_members (V = vs.80). aspx
Java: Http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Python:Http://docs.python.org/library/stdtypes.html#string-methods
Perl:, Perl is a process-orientedProgramming LanguageThere is no concept of a string object. All string-related operation functions are scattered.

Question 4: What programming style is the best for string function extensions?
String. Prototype. Trim = function ()
{
// Use a regular expression to replace spaces with empty strings.
Return this. Replace (/(^ \ s *) | (\ s * $)/g ,"");
}

Question 5: Abstract: Can I think that all operation functions are for string addition, deletion, modification, query, and type conversion?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.