Question: I am a newbie to Objective-C. I would like to display the current date and time in an alert view.

```
- (IBAction)postButtonPressed:(UIButton *)sender  {

    NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"MMM d, yyyy h:mm" options:0 locale:[NSLocale currentLocale]];

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:formatString];

    NSString *todayString = [dateFormatter stringFromDate:[NSDate date]];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Posted" message:@"Your Message is posted on: @todayString" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [alert show];
      }

```

Answer: 
Change the regex to 

```
([0-9]{2}:[0-9]{2}[AP]M)

```

Thhe brackets around (A|P) are defining it as the capture group. You need the the whole time string to be captured. So put the brackets around the whole thing.
Because the split function separator is not included in the results.  

If you want it to remain as a split element enclose it in parenthesis 

```
string time = @"([0-9]{2}:[0-9]{2}(A|P)M)";

```

By the way, that's the reason that the 'A' and 'P' were left, because they were enclosed in parenthesis.