怎么判断一个字符串最后一个字符是反斜杠“\” js 获取字符串中最后一个斜杠后面的内容
\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u4e32\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u662f\u53cd\u659c\u6760\u201c\\u201d\u5148\u83b7\u5f97\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u7136\u540e\u8bbf\u95ee\u5b57\u7b26\u4e32\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\uff0c\u4e0e\u5b57\u7b26\u2018\\u2019\u6bd4\u8f83\u5c31\u884c\u4e86
var str = "/asdasf/asfaewf/agaegr/trer/rhh";
var index = str .lastIndexOf("\/");
str = str .substring(index + 1, str .length);
alert(str );
\u5173\u4e8ejs\u4e2d\u7684\u6570\u7ec4\u7279\u70b9\uff1a
\u6570\u7ec4\u5b9a\u4e49\u65f6\u65e0\u9700\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u3002
\u6570\u7ec4\u5b9a\u4e49\u65f6\u53ef\u4ee5\u65e0\u9700\u6307\u5b9a\u6570\u7ec4\u957f\u5ea6\u3002
\u6570\u7ec4\u53ef\u4ee5\u5b58\u50a8\u4efb\u4f55\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\uff08\u6bd4\u5982\u8bf4\u4e00\u4e2a\u5143\u7d20\u4fdd\u5b58\u6574\u578b\uff0c\u4e00\u4e2a\u5143\u7d20\u4fdd\u5b58\u5b57\u7b26\u4e32\u578b\uff0c\u8fd9\u4e2a\u5728JS\u4e2d\u662f\u53ef\u4ee5\u7684\uff09\u3002
\u6570\u7ec4\u5c31\u662f\u4e00\u7ec4\u6570\u636e\u7684\u96c6\u5408\u5176\u8868\u73b0\u5f62\u5f0f\u5c31\u662f\u5185\u5b58\u4e2d\u7684\u4e00\u6bb5\u8fde\u7eed\u7684\u5185\u5b58\u5730\u5740\uff0c\u6570\u7ec4\u540d\u79f0\u5176\u5b9e\u5c31\u662f\u8fde\u7eed\u5185\u5b58\u5730\u5740\u7684\u9996\u5730\u5740\u3002
绛旓細涓ょ鏂瑰紡鍙互鍒ゆ柇锛1銆佷腑鏂囧崰涓や釜瀛楄妭锛堣嫳鏂囦竴涓級锛屽鏋滄渶鍚庝竴涓瓧绗﹀崰涓や釜瀛楄妭锛岄偅涔堝氨鏄腑鏂銆2銆佸彲浠ヤ娇姝e垯琛ㄨ揪寮忓垽鏂渶鍚庝竴浣嶆槸鍚︿负涓枃銆
绛旓細\x0d\x0a\x0d\x0a濡傛灉 start 鎴 end 涓鸿礋鏁帮紝閭d箞瀹冨皢琚浛鎹负 0銆俓x0d\x0a\x0d\x0aa.substring (a.length-1) 鎴嚭鏈鍚庝竴涓锛屽幓鍒ゆ柇\x0d\x0a\x0d\x0aa銆俵astindexof锛堚樻渶鍚庝竴涓瓧鈥欙級 杩欐槸閭d釜瀛楁渶鍚庡嚭鐜扮殑浣嶇疆锛屽垽鏂槸涓嶆槸绛変簬瀛楃涓鐨勯暱搴 ...
绛旓細涓涓悕涓篜ath.Text鐨String瀛楃涓锛屾寜涓嬫寜閽悗锛岃嫢鏈鍚庝竴涓瓧绗鏄弽鏂滄潬鈥淺鈥濓紝灏卞垹闄ゅ弽鏂滄潬锛涘惁鍒欎笉浣滃鐞嗐
绛旓細鎴戜滑鍙互鐢String绫荤殑substring(int from,int to)鏂规硶鍘绘埅瀛楃涓浣嶇疆涓篺rom鍒皌o-1浣嶇疆鐨勫瓧绗 濡備笅锛汼tring str="1234:22:23";int i=***.lastindexof(":");甯屾湜鍙互甯姪鍒颁綘銆侸ava鏄竴闂ㄩ潰鍚戝璞$紪绋嬭瑷锛屼笉浠呭惛鏀朵簡C++璇█鐨勫悇绉嶄紭鐐癸紝杩樻憭寮冧簡C++閲岄毦浠ョ悊瑙g殑澶氱户鎵裤佹寚閽堢瓑姒傚康锛屽洜姝ava璇█...
绛旓細1锛氬瓧绗︿覆鏈塴ength灞炴銆備綘鍙互鐢╯tr[length-1]鎷垮埌鏈鍚庝竴涓瓧绗︼紝浣嗘槸杩欑鍐欐硶锛孖E浣庣増鏈祻瑙堝櫒涓嶆敮鎸侊紝濡傛灉浣犳兂鍐欏吋瀹癸紝閭d箞灏辩敤涓嬮潰鐨勫啓娉曪細str.charAt(length-1);charAt()鏂规硶鏀寔鎵鏈夋祻瑙堝櫒
绛旓細js鑾峰彇涓涓瓧绗︿覆鏈鍚鐨勪竴涓瓧绗︼紝鍙互鍙傝冨涓嬫柟娉 锛氭柟娉曚竴锛氳繍鐢⊿tring瀵硅薄涓嬬殑charAt鏂规硶 charAt() 鏂规硶鍙繑鍥炴寚瀹氫綅缃殑瀛楃銆俿tr.charAt(str.length _ 1)璇锋敞鎰忥紝JavaScript 骞舵病鏈変竴绉嶆湁鍒簬瀛楃涓茬被鍨嬬殑瀛楃鏁版嵁绫诲瀷锛屾墍浠ヨ繑鍥炵殑瀛楃鏄暱搴︿负 1 鐨勫瓧绗︿覆 鏂规硶浜岋細杩愮敤String瀵硅薄涓嬬殑substr鏂规硶 ...
绛旓細(name)琛ㄧず涓鍏辨湁澶氬皯涓湁鏁堝瓧绗︼紝鑰瀛楃涓鐨鏈鍚庝竴浣嶇殑鏁扮粍浣嶅簭搴旇鏄暟缁勯暱搴﹀噺1銆傛墍浠ュ氨鍙互浣跨敤涓嬮潰鏂瑰紡鏉ヨ繘琛鍒ゆ柇锛歩f (name [strlen (name) - 1] == 'y'){ ...} 褰撶劧瀵逛簬c++锛屽洜涓烘湁string绫伙紝鎵浠ヨ繕鏈夊熀浜巗tring绫荤殑鎴愬憳鍑芥暟鐨勫疄鐜版柟寮忥紝浣嗘槸鍏跺疄鐜板師鐞嗛兘鏄繖鏍风殑銆備笉鏄庣櫧鍙互杩介棶銆
绛旓細涓绉嶆柟娉曟槸浜嬪厛鐭ラ亾鏈夊灏戜釜瀛楃涓查渶瑕佽緭鍑 鍙︿竴绉嶆柟娉曟槸锛鏈鍚庝竴涓瓧绗︿覆鐨勫悗闈紝璺熼殢绌轰覆锛屽嵆瀛楃涓叉暟缁勭殑绗1涓厓绱犲瓨鏀惧瓧绗︿覆缁撳熬绗0锛屽湪杈撳嚭鍓鍒ゆ柇涓涓嬫槸鍚︾┖涓诧紝閬囧埌绌轰覆灏辩粨鏉熻緭鍑恒俢har name[10][20]={ "灏忕帇","寮犱笁","鏉庡洓","" }; int i;i=0; while ( name[i][0]!=0 ) ...
绛旓細涓句釜渚嬪瓙锛歩nclude<stdio.h> define N 10 int strchangdu(char str[]){ int i=0;for( ;str[i];i++);return i;} void main(){ char s[N];scanf("%s",s);printf("瀛楃涓鐨勯暱搴︽槸锛%d\n",strchangdu(s));} 瀛楃涓叉槸浠'\0'缁撳熬鐨勬墍浠ラ亣鍒板畠灏辫〃绀哄瓧绗︿覆缁撴潫 ...
绛旓細char s[] = "12345";int len = strlen(s);s[len-1]灏辨槸鏈鍚庝竴涓鏈夋晥瀛楃锛宻[len]鏄渶鍚庝竴涓粨鏉熺瀛楃鍗0銆傚氨鐪嬩綘鏈鍚庝竴涓槸鎸囧摢涓