字符串操作
Posted 虚镜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了字符串操作相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>字符串操作</title> </head> <body> <script type="text/javascript"> //声明字符串 var str = ‘@[email protected]@‘;// //获取字符串的长度 var len = str.length; // /常用的方法 var res = str.trim(‘@‘); //获取指定索引的字符 $str[] $str{} var res = str.charAt(4);//char字符 at 在...地方 //strpos var res = str.indexOf(‘o‘); //strrpos var res = str.lastIndexOf(‘o‘); //连接字符串 + 想起arguments var res = str.concat(‘verymuch‘,‘ and you???‘); //截取字符串 var res = str.slice(2, 7); var res = str.substring(2, 7); //字符串拆分 var res = str.split(‘@‘); // console.log(res); //截取字符串 var res = str.substr(2, 4); //大写转换 var res = str.toUpperCase(); //小写转换 var res = str.toLowerCase(); //字符串替换 var res = str.replace(‘love‘,‘like‘); // </script> </body> </html>
以上是关于字符串操作的主要内容,如果未能解决你的问题,请参考以下文章
VSCode自定义代码片段15——git命令操作一个完整流程