Question: This ought to be pretty simple, maybe use a regex but I would think there is an easier - faster way. Currently I make this work by using a couple of splits, but that sure seems like a poor method.

Example string:

> 
> on Jun 09, 2009. Tagged:
> 
> 
> 

What I need to do is turn that date (June 09, 2009) into three strings (Jun, 09, 2009). Obviously this date may vary to things like May 25, 2011. I assume using the two outside strings which would be consistent ("on " and ". Tagged") and searching based on them is the best method. The month will always be three letters.

What would be a better way to do this via Javascript?

Thanks!

Answer: 
You could do it using substring commands, but a regex would be simpler and less prone to breaking if the source data ever changed.

You can use this regex:

```
 var input = "on Jun 09, 2009 Tagged:";
 var date = input.match(/([a-zA-Z]{3}) (\d{1,2}), (\d{4})/);
 // date = ["Jun 09, 2009", "Jun", "09", "2009"];
 var simpledate = date.slice(1);
 // simpledate = ["Jun", "09", "2009"];

```

When using RegEx's, I find this site to be extremely useful: <http://www.regular-expressions.info/javascriptexample.html>

It provides a JavaScript regex tester that's very handy! You can plug in same data and a regex and run it and see the matched data. It's helped me to understand regular expressions a lot better. For example, you can see that my regex and the other answers are different but accomplish the same thing.
You could use a regular expression:

```
var match = str.match(/on (\w+) (\d{2}), (\d{4})\. Tagged/);
// match = ["on Jun 09, 2009. Tagged", "Jun", "09", "2009"]

```