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
    00
    2010-05-05T12:37:00+0000


    • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
    Comment
     
    Verify
    Comment