views:

48

answers:

1

Hi All,

I've got a regular expression in my cocoa-touch app (using RegexKitLite).

    NSString *week = [[NSString alloc] initWithFormat:@"%@", [pageContent stringByReplacingOccurrencesOfRegex:@"<select name=\"week\" class=\"selectbox\" style='width:134' onChange=\"doDisplayTimetable(NavBar, topDir);\">(.+?)<option value=\"(.+?)\">(.+?)</option>" 
                                                                                               withString:@"$2"]];

I expect it to match with the section of this (what is in NSString pageContent):

  <span class="selection">
   <nobr>
    Periode<br>
    <span class="absatz">
     &nbsp;<br>
    </span>
    <select name="week" class="selectbox" style='width:134' onChange="doDisplayTimetable(NavBar, topDir);">
<option value="14">17-5 - 16-7</option>
    </select>
   </nobr>
  </span>

But it doesn't... I need the value of the option, it is possible that there is more than one (in that case I need them both separated by a ,.

Can someone help me out?

Regards, Dodo

+2  A: 

Leaving required "OMGPARSINGHTMLWITHREGEX" comment to someone else, your regex doesn't work because you need to mask brackets here: onChange="doDisplayTimetable\(NavBar, topDir\);"

Then if you need to get more than one option, I would do it in two steps - first extract your <select>...</select> block, then write another regexp to match all <option>...</option> inside it.

serg