I want to extract the episode number from the name of TV Series.
e.g. If it is "Game of Thrones S06E01", Then I should get 01.
What I am trying is :
Praise the power of regular expressions then:
\b(?i)S\d+E(\d+)(?i-)\b
PHP
this would be:
<?php
$data = <<<DATA
Blacklist S01E01
Blacklist s01e01 (small "e" and "s")
Blacklist S01E01.mkv
Se7en S01E01
DATA;
$regex = '~\b(?i)S\d+E(\d+)(?i-)\b~';
preg_match_all($regex, $data, $matches);
print_r($matches);
?>
And see a demo on ideone.com.
jQuery/JavaScript
, you need to change the inline modifiers:
\bS[\d.]+E(\d+)\b
See a demo on regex101.com (and mind the modifiers!).