forked from cloudacademy/static-website-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stringtopattern.html
48 lines (34 loc) · 1.22 KB
/
stringtopattern.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function sync()
{
var n1 = document.getElementById('n1');
var n2 = document.getElementById('n2');
var moonlanguage = ""
for (var i = 0; i < n1.value.length; i++) {
var regextest1 = RegExp('[a-zA-Z]');
var regextest2 = RegExp('\\(|\\)|\\.|\\%|\\+|\\-|\\*|\\?|\\[|\\]|\\^|\\$');
if (regextest1.test(n1.value[i])) {
moonlanguage = moonlanguage.concat('[',n1.value[i].toLowerCase(), n1.value[i].toUpperCase(),']');
} else if (regextest2.test(n1.value[i])) {
moonlanguage = moonlanguage.concat('%',n1.value[i]);
} else {
moonlanguage = moonlanguage.concat(n1.value[i]);
} ;
};
n2.innerHTML = moonlanguage;
}
</script>
<h1>String to Lua</h1> <input type="text" name="n1" id="n1" onkeyup="sync()" size="128" style="font-size:25px;" />
<br>
<h1>Case Insensitive Pattern</h1>
<pre name="n2" id="n2" style="font-size:25px;">-----</pre>
<br>
<p>Lua patterns are similar to Regex, but different. See the following link for details. <a href="https://www.lua.org/pil/20.2.html">https://www.lua.org/pil/20.2.html</a> </p>
<p>Also, check out the whitelist and violations decoder tool: <a href="/decoder.html">Decoder</a></p>
</body>
</html>