javascript string handling functions summary

2010-04-12  来源:本站原创  分类:Web  人气:270 

While JavaScript has many useful, but processing the string is one of the most popular one. Let us in-depth analysis of the use of JavaScript string operation.

In the JavaScript in, String is the object. String objects are not stored as character arrays, so we must use the built-in function to manipulate their values. These built-in functions provide different ways to access the contents of a string variable. Here we look at these functions in detail.

Operation of the string value is the average developer must face routine. Operation of the string there are many specific ways, for example, the string is extracted from a part to, or determine whether a string contains a specific character. The following JavaScript function for the developers with all the features they need:

• concat () - two or more characters of text together, returning a new string.

<script type="text/javascript">
var str1="Hello "
var str2="world!"
document.write(str1.concat(str2))
</script>

• indexOf () - returns a substring of the string appears at the first index. If no match, returns -1.

• charAT () - Returns the character position.

• lastIndexOf () - returns a string substring index of the last one there, if there is no match, returns -1.

• match () - Check whether a string matches a regular expression.

• substring () - returns the string of a substring. Incoming parameter is the start position and end position.

• replace () - used to match a regular expression search string, then use the new string to replace the matched string.

• search () - perform a regular expression match to find. If successful, search returns the index value matches the string. Otherwise, it returns -1.

• slice () - extract a part of the string, and returns a new string.

• split () - divided into sub-string by string, a string made of an array of strings.

• length () - returns the length of the string, the so-called length of the string is the number of characters it contains.

• toLowerCase () - convert the entire string to lowercase.

• toUpperCase () - transfer the entire string uppercase.
This article comes from: Development Institute http://edu.codepub.com Original link: http://edu.codepub.com/2009/0416/3001.php

相关文章
  • javascript string handling functions summary 2010-04-12

    While JavaScript has many useful, but processing the string is one of the most popular one. Let us in-depth analysis of the use of JavaScript string operation. In the JavaScript in, String is the object. String objects are not stored as character arr

  • Oracle common type of characters and string handling functions 2010-03-15

    ##################################### # Commonly used class of character and string handling functions ##################################### # LOWER function function: to convert a string into lowercase letters example: select firstname, lastname fro

  • JSTL in string handling functions 2010-07-07

    JSTL string handling functions JSTL expressions to simplify the page using the code, which some of the standard methods, such as bean's getter / setter methods, as well as request parameter or session in the context of data access is very convenient,

  • PHP string handling functions (b) 2010-11-10

    explode () String partition function, which returns a string array is divided. Parameters (a total of three, an optional): explode (separator, necessary to split the string, [optional parameters, an integer, returns the maximum number of elements in

  • String handling functions and the number of statistical words 2011-05-29

    First, the string handling functions 1, puts (character array) Its role is a string (with '\ 0' end of the sequence of characters) output to the terminal. If str is a string defined array of names, and the array has been initialized to "China",

  • Simple string handling functions 2010-04-07

    Long time no write C programs, and the writing of it is customary to the Internet to find ready-made program, but simple to write about than their own, when the study was. Just to deal with strings, let us begin from the string handling. /** * To det

  • Oracle string handling functions 2010-06-02

    Projects involving stored procedure on the strings, so I will find the information in the online summary, make a mosaic-style summary of the information. The following information comes from the Internet, posted a save to be their own later use, one

  • oracle stored procedures commonly used string handling functions 2011-05-12

    Project has involved the handling of the string stored procedures, so will find information on the Internet summary, make a mosaic-style summary of the information. The following information comes from the Internet, posted a save to be after their us

  • Js finishing several important string handling functions and Application 2010-05-07

    Function: split () Function: Use a specified separator to split a string into an array of storage example: str = "jpg | bmp | gif | ico | png"; arr = theString.split ("|"); / / Arr is a character value that contains "jpg", &q

  • js commonly used string handling functions 2010-11-03

    Function: split () Function: Use a specified separator to split a string stored in the array example: theString = "jpg | bmp | gif | ico | png"; arr = theString.split ("|"); / / Arr is a character value contains "jpg", "

  • sql string handling functions 2011-08-17

    --wmsys.wm_concat Function SELECT wmsys.wm_concat(ename) FROM emp WHERE deptno = 10; SELECT empno, wmsys.wm_concat(ename) OVER( ORDER BY empno,sal) FROM emp WHERE deptno = 10; SELECT empno,wmsys.wm_concat(ename) OVER(PARTITION BY deptno) FROM emp; --

  • flex (AIR) Chinese garbled string handling functions 2010-06-19

    private function encodeUtf8(str: String):String{ // Give him a text string, you can ensure that its return value is the Chinese if(str != null && str != "undefined"){ var oriByteArr: ByteArray = new ByteArray(); oriByteArr.writeUTFBytes(

  • PHP string handling functions Daquan 2010-09-03

    AddSlashes: string to slash. bin2hex: binary conversion hexadecimal. Chop: remove the blank row. Chr: return value of the character sequence. chunk_split: the string into short paragraphs. convert_cyr_string: convert strings into other strings Guslav

  • PHP string handling functions (a) 2010-11-10

    1, strlen () / / get string length function 2, ltrim () / / remove the string on the left of the box 3, rtrim () / / remove the string to the right of space 4, trim () / / remove the spaces on both sides of the string 5, strrev () / / reverse the ord

  • JavaScript string formatting functions 2010-12-28

    Whim, drawing achieved Extjs string formatting: Version 1: str = "abc:{name},cde:{code}"; String.prototype.format = function(obj){ if (arguments.length == 0) return ''; return this.replace(/\{[\w]*\}/g,function(match){ return obj[match.replace(/

  • Two VB string handling functions (like Left / Mid / Right / Split combination) 2011-03-09

    Function Name: 1, ParameterValue () 2, ParameterCount () Example usage: Dim StrTest as String StrTest = "Welcome; visit; JiaJia; Blog; VB source code" Debug.Print ParameterCount (";", StrTest) 'Back 5 Debug.Print ParameterValue ("

  • mysql string handling functions 2011-03-28

    CONCAT(str1,str2,...) Return link from the argument string. If any parameter is NULL, return NULL. Can have more than 2 parameters. A numeric argument is converted to equivalent string. mysql> select CONCAT('My', 'S', 'QL'); -> 'MySQL' mysql> sel

  • Oracle frequently used characters and string handling class functions 2010-03-15

    ##################################### # Commonly used class of character and string handling functions ##################################### # LOWER function function: to convert a string into lowercase letters example: select firstname, lastname fro

  • PHP string functions summary 2010-11-05

    PHP string functions summary ================================== ceil, floor, round, /,% float ceil (float $ value) to go the whole (further) cout (1.8) => 2 cout (-1.8) => 2-1 float floor (float $ value) to go the whole (down) floor (1.8) => 1 fl

  • Chapter VII of the JavaScript exception handling 2010-05-04

    1.Array object to use 2.Date object to use 3.Math object to use 1.JavaScript in the dialog box 2. Learn JavaScript Exception Handling 3. To resolve anomalies in JavaScript JavaScript in the dialog box 1.alert (): method used to display the specified