Posted By

mlange on 10/03/06


Tagged

String


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

rnrleachryan
vali29


String Functions


 / Published in: JavaScript
 

URL: http://www.javascriptkit.com/javatutors/string4.shtml

Source: strings @ javascriptkit.com

  1. charAt(x)
  2. /*
  3. Returns the character at the "x" position within the string.
  4. */
  5.  
  6. charCodeAt(x)
  7. /*
  8. Returns the Unicode value of the character at position "x" within the string.
  9. */
  10.  
  11. concat(v1, v2,...)
  12. /*
  13. Combines one or more strings (arguments v1, v2 etc) into the existing one and returns the combined string. Original string is not modified.
  14. */
  15.  
  16. fromCharCode(c1, c2,...)
  17. /*
  18.  Returns a string created by using the specified sequence of Unicode values (arguments c1, c2 etc). Method of String object, not String instance. For example: String.fromCharCode().
  19. */
  20.  
  21. indexOf(substr, [start])
  22. /*
  23. Searches and (if found) returns the index number of the searched character or substring within the string. If not found, -1 is returned. "Start" is an optional argument specifying the position within string to begin the search. Default is 0.
  24. */
  25.  
  26. lastIndexOf(substr, [start])
  27. /*
  28. Searches and (if found) returns the index number of the searched character or substring within the string. Searches the string from end to beginning. If not found, -1 is returned. "Start" is an optional argument specifying the position within string to begin the search. Default is string.length-1.
  29. */
  30.  
  31. match(regexp)
  32. /*
  33. Executes a search for a match within a string based on a regular expression. It returns an array of information or null if no match is found.
  34. */
  35.  
  36. replace( regexp, replacetext)
  37. /*
  38. Searches and replaces the regular expression portion (match) with the replaced text instead.
  39. */
  40.  
  41. search(regexp)
  42. /*
  43. Tests for a match in a string. It returns the index of the match, or -1 if not found.
  44. */
  45.  
  46. slice(start, [end])
  47. /*
  48. Returns a substring of the string based on the "start" and "end" index arguments, NOT including the "end" index itself. "End" is optional, and if none is specified, the slice includes all characters from "start" to end of string.
  49. */
  50.  
  51. split(delimiter, [limit])
  52. /*
  53. Splits a string into many according to the specified delimiter, and returns an array containing each element. The optional "limit" is an integer that lets you specify the maximum number of elements to return.
  54. */
  55.  
  56. substr(start, [length])
  57. /*
  58. Returns the characters in a string beginning at "start" and through the specified number of characters, "length". "Length" is optional, and if omitted, up to the end of the string is assumed.
  59. */
  60.  
  61. substring(from, [to])
  62. /*
  63. Returns the characters in a string between "from" and "to" indexes, NOT including "to" inself. "To" is optional, and if omitted, up to the end of the string is assumed.
  64. */
  65.  
  66. toLowerCase()
  67. /*
  68. Returns the string with all of its characters converted to lowercase.
  69. */
  70. toUpperCase()
  71. /*
  72. Returns the string with all of its characters converted to uppercase.
  73. */

Report this snippet  

You need to login to post a comment.