JavaScript Program to Check Whether String Containg letters 'a' and 'c' Using Regular Expression

Write a JavaScript program to check whether string containg letters 'a' and 'c' using regular expression.



Source Code
<html>
<head>
    <title>Regular expression - Checking given letters</title>
</head>
<body>
    <script language="javascript">
        var input = prompt('Enter some text')
        re = /[ac]/
        if(re.test(input))
        {
            alert('The string contains letter a or c or both')
        }
        else
        {
            alert('String does not contain a or c or both')
        }
    </script>
</body>
</html>
Output