I have the following input string:
02:00:00_03:00:[email protected]
or this :
02:00:00_03:00:[email protected]
I'm trying to write a javascript regex that will match both. The "mtwrf" is optional... it may or may not be present in the input.
I've been using this site to test: http://www.regexpal.com/
This pattern:
(\d\d\:\d\d:\d\d\_){2}([mtwrfsn\_]*)([\w\d]+\@?[\w\d\.]+)
seems to work as per the regexpal.com website using the input string:
02:00:00_03:00:[email protected]
But ... when I plug that into my code... it's not matching / finding the "02:00:00".
Here's my javascript code:
var pattern = /(\d\d\:\d\d:\d\d\_){2}([mtwrfsn\_]*)([\w\d]+\@?[\w\d\.]+)/;
if (rules_array[i].length > 0) {
searchval = rules_array[i].match(pattern);
}
console.log(searchval);
And the output I get is this:
[ '02:00:00_03:00:[email protected]',
'03:00:00_',
'',
'[email protected]',
index: 0,
input: '02:00:00_03:00:[email protected]' ]
I think i should be seeing something like this instead:
[ '02:00:00_03:00:[email protected]',
'02:00:00_',
'03:00:00_',
'[email protected]',
index: 0,
input: '02:00:00_03:00:[email protected]' ]
Can you see where my bug / problem is? Thanks.