Lpad()函數(shù)的用法: lpad函數(shù)將左邊的字符串填充一些特定的字符其語法格式如下: lpad(string,n,[pad_string]) stri
Lpad()函數(shù)的用法:
lpad函數(shù)將左邊的字符串填充一些特定的字符其語法格式如下:
lpad(string,n,[pad_string])
string:可是字符或者參數(shù)
n:字符的長度,是返回的字符串的數(shù)量,如果這個數(shù)量比原字符串的長度要短,,lpad函數(shù)將會把字符串截取成從左到右的n個字符;
pad_string:是個可選參數(shù),這個字符串是要粘貼到string的左邊,如果這個參數(shù)未寫,lpad函數(shù)將會在string的左邊粘貼空格。
例如:
lpad('tech', 7); 將返回' tech'
lpad('tech', 2); 將返回'te'
lpad('tech', 8, '0'); 將返回'0000tech'
lpad('tech on the net', 15, 'z'); 將返回 'tech on the net'
lpad('tech on the net', 16, 'z'); 將返回 'ztech on the net'
—————————————
Rpad()函數(shù)的用法:
rpad函數(shù)將右邊的字符串填充一些特定的字符其語法格式如下:
rpad(string,n,[pad_string])
string:可是字符或者參數(shù)
n:字符的長度,是返回的字符串的數(shù)量,如果這個數(shù)量比原字符串的長度要短,lpad函數(shù)將會把字符串截取成從左到右的n個字符;
pad_string:是個可選參數(shù),這個字符串是要粘貼到string的右邊,如果這個參數(shù)未寫,lpad函數(shù)將會在string的右邊粘貼空格。
例如:
rpad('tech', 7); 將返回' tech'
rpad('tech', 2); 將返回'te'
rpad('tech', 8, '0'); 將返回'tech0000'
rpad('tech on the net', 15, 'z'); 將返回 'tech on the net'
rpad('tech on the net', 16, 'z'); 將返回 'tech on the netz'
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com