Javascript intercepts the specified string from the right in three ways
- 2020-03-30 00:01:10
- OfStack
Intercept fg to the right of abcdefg
Methods a
< Script>
String = "abcdefg"
Alert (string, the substring (string length 2, the string. Length))
< / script>
Method 2
< Script>
Alert (" abcdefg ". The match (/. * (. {2}) /) [1])
< / script>
< Script>
Alert (" abcdefg ". The match (/. {2} $/))
< / script>
Methods 3
< Script>
Alert (" abcdefg ". Slice (-) 2) // this one is recommended. It is relatively simple. -2 means to take the two characters on the right
< / script>