首页 > 代码库 > 04_JavaScript

04_JavaScript

 

String对象

match()找到一个或多个正则表达式的匹配

substr()从起始索引号提取字符串中指定数目的字符

substring()提取字符串中两个指定的索引号之间的字符

 

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>String对象</title>
		<script>
			var str = "-a-b-c-d-e-f-";
			var str1 = str.substr(2, 4); //-b-c
			var str2 = str.substring(2, 4); //-b
			alert(str2);
		</script>
	</head>

	<body>
	</body>

</html>

 

04_JavaScript