I'm very new to javascript and i'm working on a small form to get the episode and season numbers from tv shows from release names ie I input Chicago Fire S01E11 480p HDTV x264-mSD and it only extracts S01E11 with regexp. But now I realized theres a small problem when the episodes are more than 2 digits long. I added if statements for if it fails to find the string S##E## to try S##E### and try all the combinations of 2 and 3 digit numbers until none of them work and it should add to the other textbox that you inputted wrong. Now it still only works for only 2 digits seasons and episodes and i dont know how to get it to figure out if a show has 3 digits episodes and/or seasons and use the alternative search. Here is where im at right now if anyone can help me get it to work would be highly appreciated.
Code:
<html>
<body>
<script type="text/javascript">
function filtering()
{
var str = document.form1.inTB.value;
var filter1 = /\sS..E../;
var filtered1 = str.match(filter1);
if (filtered1.length == 0)
{
var filter1 = /\sS..E.../;
var filtered1 = str.match(filter1);
}
if (filtered1.length == 0)
{
var filter1 = /\sS...E.../;
var filtered1 = str.match(filter1);
}
if (filtered1.length == 0)
{
var filter1 = /\sS...E../;
var filtered1 = str.match(filter1);
}
if (filtered1.length == 0)
{
var filter1 = /\sS..E.../;
var filtered1 = str.match(filter1);
}
if (filtered1.length == 0)
{
var filtered1 = "You inputted wrong.";
}
document.form1.outTB.value = filtered1;
}
</script>
<form name="form1" method="post" action="">
<input name="inTB" type="text" id="inTB" value="" size="30">
<br>
<input type="button" name="" value="Filter" onClick="filtering();">
<br>
<input name="outTB" type="text" id="outTB" value="" size="30">
</form>
</body>
</html>