Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created August 2, 2016 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/528872aa8853b22151325990506d60fc to your computer and use it in GitHub Desktop.
Save jianminchen/528872aa8853b22151325990506d60fc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<head>
<title></title>
<style>
p {
color: blue;
margin: 8px;
}
b {
color: red;
}
</style>
</head>
<body>
<p><b>String </b> Match</p>
<p>this is a JavaScript String study practice </p>
<p id="test">test..</p>
<script type="text/javascript">
var str = $( "p:first" ).text();
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var regexp = /[A-E]/gi;
var matches_array = str.match(regexp);
$('#test').html = matches_array[0]; // include Jquery library
$( "p:last" ).html( matches_array.indexOf('d') );
console.log(matches_array);
// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment