Forum

Heyxu Forum

Forum Dictionary / Programming / 網頁/網站程式 / JavaScript /

取得部份字串的函式

New Subject
Random
Previous
Next
|
取得部份字串的函式

JavaScript 中的取得部份字串的函式有 substr 和 substring 兩者之間有一點些微的不同:

String.substr(N1,N2) :從指定的位置(N1)向後截取指定長度(N2)的字串。

例:
var a="654321";
alert(a.substr(1,2)) 結果:54

String.substring(N1,N2) :從指定的位置(N1)到指定的位置(N2)的字串。

例:
var a="654321";
alert(a.substring(1,2)) 結果:5

  • Keywords : 位置, substring, substr, 從指定, 字串, alert, String, 654321, 長度, 到指定, 函式, 兩者, 不同, 一點些微, JavaScript
0 0
2010-05-05T12:37:00+0000


  • Now, you can post comments by Facebook Account when your Heyxu account was logout or unvariable. whatever, we suggest to post comment by Heyxu Account to get more bounds to join new events of Heyxu
Comment
Verify
Comment
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Copyright
    © 2009 Heyxu Multimedia, Inc - All rights reserved.
  • Revised Version
    V2.1.341
    12 Apr 2019 (GMT+8)