Regular Expression Switch : Regular Expressions « Development « JavaScript DHTML
- JavaScript DHTML
- Development
- Regular Expressions
Regular Expression Switch
<html>
<head>
<title>Regular Expression Switch</title>
</head>
<body>
<script type="text/javascript">
var rgExp = /(\w*)-*(\w*)/
var str = "AAAA--BBBB";
var resultStrng = str.replace(rgExp,"$2-$1");
document.writeln(resultStrng);
</script>
</body>
</html>
Related examples in the same category