Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://xregexp.com/v/3.0.0/xregexp-all-min.js"></script>
<script>
var regex = XRegExp('([\\p{Lu}]+[\\p{Ll}]+|[\\p{Ll}]+[\\p{Lu}]+)|[0-9]+[\\p{Lu}\\p{Ll}]+|[\\p{Lu}\\p{Ll}]+[0-9]+|([^\\p{L}0-9])+');
console.log("Ola1: "+regex.test("Ola1"));
console.log("olá: "+regex.test("olá"));
</script>
<title>Hey</title>
</head>
<body>
</body>
</html>
Result: (see console)
Ola1: true
olá: false
Explanation:
Step 1: Include this script (http://xregexp.com/v/3.0.0/xregexp-all-min.js) in html
<script src="http://xregexp.com/v/3.0.0/xregexp-all-min.js"></script>
Step 2: Declare regex to be used
var regex = XRegExp('([\\p{Lu}]+[\\p{Ll}]+|[\\p{Ll}]+[\\p{Lu}]+)|[0-9]+[\\p{Lu}\\p{Ll}]+|[\\p{Lu}\\p{Ll}]+[0-9]+|([^\\p{L}0-9])+');
Step 3: Utilise
var resultado = regex.test("string a testar");
If the result variable is true then the string has some of the cases. Otherwise, it does not have.
You only need the external script because regex in javascript cannot recognize non-English letters (á, Á, ç, é, í, etc.)
If you don’t need to recognize these letters just use:
var regex = /(([a-z]+[A-Z]+|[A-Z]+[a-z]+)|([0-9]+[A-Za-z]+)|([a-zA-Z]+[0-9])+|([\W]))/;
var resultado = regex.test("string a testar");
Do you just want to know if you have it, or do you want to do something with the data if you have it? The question is a little vague.
– Bacco
Only if there is, then depending on whether or not I will do actions on other objects, but not on that data.
– Leonardo
I get it. Here you may already have something that helps: http://answall.com/search?q=jquery+regex . I remember seeing something good without Regex too, to validate passwords, already ready on the site. If I find warning. Remembering that, if to use the data on some server-side system, you have to check on the server side as well.
– Bacco
Some similar things, see if any fit: Mount Regex to validate password and Password check.
– Bacco