I need to count a group of regular expressions in a dynamically loaded <div> that I’ve loaded using the load() function. I also need to resize this <div> to the longest line of characters in it. Is there a way to achieve this? I’ve tried searching around and can’t find anything, not even on SO. I should mention that the expression I am testing for is:
Sat Mar 12 12:45:38 PST 2011
Using this regex:
if ($('#result').text().match(/[A-Za-z]{3}\s[A-Za-z]{3}\s[0-9]{1,2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]{3}\s[0-9]{4}/))
JavaScript match regex function returns an array so you can basically do a length on that array and get the size of the matched elements. Make sure you are using the
gin RegEx to search all occuranceBased on your RegEx you can do the following: