0

I am trying to get an NSDate from a string. The problem I am having is that the date I need is within a text.

Example: “Expieres : 26 May 2015 140 days left”.

I would like “26 May 2015” out of that and convert it into an NSDate. Would I use Regular expression, then convert the string to NSDate. If so, what would the regular expression look like.

Any help would be appreciated, thanks in advance.

Erion S
  • 1,603
  • 18
  • 24

1 Answers1

3

There are gazillion ways to match the date. Depending on the actual input and purpose, you may or may not need a strong regex to match what you want.

One simple solution (while reasonably strict) is:

@"\\d{2} [A-Za-z]+ \\d{4}"
nhahtdh
  • 55,989
  • 15
  • 126
  • 162