SHELL---string interception
1, by the specified string interception (4 kinds)
${varible##*string} # to truncate the strings after the last string from left to right < delete the left character, leaving the right character > ${varible#*string} # to truncate the strings after the first string from left to right < delete the left character, leaving the right character > ${variblepercent string*} # intercepts the string after the last string from right to left < removes the right character, leaving the left character > ${varible%string*} # intercepts the string after the first string from right to left < Deletes the right character, leaving the left character > |
Note: varible variable name
String to be intercepted by string
"*" is just a wildcard can not
Examples and operating results:
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/82/D9/wKiom1dib53wNm3fAADwjzFW1lw749.jpg "title=" ##%%. JPG "alt=" wkiom1dib53wnm3faadwjzfw1lw749.jpg "/>
2, according to the specific character offset and length, using another form of variable extension, to select a specific substring. (4 types)
This form of string truncation is simple, with only a colon separated to specify the starting character and substring length.
${varible: Start:len} # starts with the left (start+1) character and the number of characters Len ${varible:start} # starts from the left (start+1) character until the end of the page ${varible: 0-start:len} # starts with the first character on the right and the number of characters Len ${varible: 0-start} # starts with the start character on the right and ends at the end of the page |
Note: varible variable name
start character begin position the first character on the left is denoted by 0, and the first character on the right is denoted by 0-1.
Len Character Count
Examples and operating results:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/82/DA/wKiom1difsiDSEfMAADx1I51c0I646.jpg "title=" ::: 2.jpg "alt=" Wkiom1difsidsefmaadx1i51c0i646.jpg "/>
This article is from the "Flower Open Shore" blog, please be sure to keep this source http://zxtong.blog.51cto.com/10697148/1790030
Shell----String interception method Induction