Question: ```
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2009&nbsp;RX7)</font></td>
>monospace" size="-1">214869&nbsp;(2007&nbsp;PAZ)</font></td>
>monospace" size="-1">&nbsp;&nbsp;4155&nbsp;Accord</font></td>

```

I wonder if someone could offer me a little help, I have a list of NSString items (See Above) that I want to parse some data from. My problem is that there are no tags that I can use within the strings nor do the items I want have fixed positions. The data I want to extract is:

```
2009 RX7
2007 PAZ
4155 Accord

```

My thinking is that its going to be easier to parse from the right hand end, remove the `</font></td>` and then use ";" to separate the data items:

```
(2009&nbsp RX7)
(2007&nbsp PAZ)
4155&nbsp Accord

```

which can them be cleaned up to match the example given. Any pointers on doing this or working through from the right would be very much appreciated.

Answer: 
Try this code:

```
NSString *str = @">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2009&nbsp;RX7)</font></td>";
NSRange fontRange = [str rangeOfString:@"</Font>" options:NSBackwardsSearch];
NSRange lastSemi = [str rangeOfString:@";" options:NSBackwardsSearch range:NSMakeRange(0, fontRange.location-1)];
NSRange priorSemi = [str rangeOfString:@";" options:NSBackwardsSearch range:NSMakeRange(0, lastSemi.location-1)];
NSString *yourString = [str substringWithRange:NSMakeRange(priorSemi.location+1, fontRange.location-1)];

```

The key element here is the `NSBackwardsSearch` search option.
Using `NSRegularExpression`:

```
NSRegularExpression *regex;
NSTextCheckingResult *match;

NSString *pattern = @"([0-9]+)&nbsp;([A-Za-z0-9]+)[)]?</font></td>";
NSString *string = @">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(2009&nbsp;RX7)</font></td>";

regex = [NSRegularExpression
         regularExpressionWithPattern:pattern
         options:NSRegularExpressionCaseInsensitive
         error:nil];

match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])];
NSLog(@"'%@'", [string substringWithRange:[match rangeAtIndex:1]]);
NSLog(@"'%@'", [string substringWithRange:[match rangeAtIndex:2]]);

```

NSLog output: 

'2009'  

'RX7'