JS String Learning Notes

Source: Internet
Author: User

Several functions are commonly used:

CharAt () returns the character at the specified position.

Concat () connection string, similar to +.

IndexOf () returns the index position of the specified string. Note is a string.

Match () finds the matching of one or more regular expressions. The regular is not used ....

SUBSTR () extracts the specified number of characters from the starting index number in the string. For example: Str1.substr (0,1) 1 characters starting at index 0, that is, the first character. The second parameter is optional.

SUBSTRING () extracts the characters between two specified index numbers in a string.

Cases:

var str1= "Hello";
document.write (str1.substring (0,2)); will return he, notice that the return is not hel


Some of the other operations are to display strings in a number of different formats.


Here's a w3school about string manipulation.

String Object Properties
Properties Description
Constructor A reference to the function that created the object
Length The length of the string
Prototype Allows you to add properties and methods to an object
String Object method
Method Description
Anchor () Creates an HTML anchor.
Big () Displays the string in a large font.
Blink () Displays the flashing string.
Bold () Use bold to display the string.
CharAt () Returns the character at the specified position.
charCodeAt () Returns the Unicode encoding of the character at the specified position.
Concat () The connection string.
Fixed () Displays the string as a typewriter text.
FontColor () Displays the string using the specified color.
FontSize () Displays the string using the specified dimensions.
fromCharCode () Creates a string from character encoding.
IndexOf () Retrieves a string.
Italics () Use italic to display strings.
LastIndexOf () The string is searched forward from the back.
Link () Displays the string as a link.
Localecompare () Compares two strings in a local-specific order.
Match () Finds a match for one or more regular expressions.
Replace () Replace the substring that matches the regular expression.
Search () Retrieves a value that matches a regular expression.
Slice () Extracts a fragment of a string and returns the extracted part in a new string.
Small () Use a small font size to display the string.
Split () Splits a string into an array of strings.
Strike () Use strikethrough to display strings.
Sub () Displays the string as subscript.
SUBSTR () Extracts a specified number of characters from the starting index number in a string.
SUBSTRING () Extracts the characters between two specified index numbers in a string.
SUP () Displays the string as superscript.
toLocaleLowerCase () Converts the string to lowercase.
toLocaleUpperCase () Converts the string to uppercase.
toLowerCase () Converts the string to lowercase.
toUpperCase () Converts the string to uppercase.
Tosource () Represents the source code for the object.
ToString () Returns a string.
ValueOf () Returns the original value of a string object.


JS String Learning Notes

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.