Dooley28 Posted March 4, 2008 Share Posted March 4, 2008 1. Describe your problem or background that is important to it. 2. Give sample data (the input data, the haystack...etc..) 3. Give the expected output/matches from your sample data. 4. Give the actual output that you have if you've attempted something already. 5. Provide code if necessary, if your problem concerns it. 6. We assume its a php regex related as this is phpfreaks, but you still need to specifiy (if not obvious) if you are talking about POSIX (ereg) or PCRE (preg) flavor. 7. Be patient/grateful and don't demand things. Regex questions may take longer than expected to be answered, they're tougher sometimes. Hi, Im trying to return a definition of a keyword using dictionary.com, im using curl on this site and am trying to use a regex to output the data. The specific tags I want are here. <ol type="1"><li>Something, such as a fetter, cord, or band, that binds, ties, or fastens things together.</li> <li>Confinement in prison; captivity. Often used in the plural.</li> <li>A uniting force or tie; a link: <i>the familial bond.</i></li> <li>A binding agreement; a covenant.</li> <li>A duty, promise, or other obligation by which one is bound.</li> <li><ol type="a"><li>A substance or agent that causes two or more objects or parts to cohere.</li> <li>The union or cohesion brought about by such a substance or agent.</li> <li>A written and sealed obligation, especially one requiring payment of a stipulated amount of money on or before a given day.</li> <li>A sum of money paid as bail or surety.</li> <li>A bail bondsman.</li> </ol> </li> <li>A chemical bond.</li> <li>A systematically overlapping or alternating arrangement of bricks or stones in a wall, designed to increase strength and stability.</li> <li><i>Law</i> <ol type="a"><li>A written and sealed obligation, especially one requiring payment of a stipulated amount of money on or before a given day.</li> <li>A sum of money paid as bail or surety.</li> <li>A bail bondsman.</li> </ol> </li> <li>A certificate of debt issued by a government or corporation guaranteeing payment of the original investment plus interest by a specified future date.</li> <li>The condition of taxable goods being stored in a warehouse until the taxes or duties owed on them are paid.</li> <li>An insurance contract in which an agency guarantees payment to an employer in the event of unforeseen financial loss through the actions of an employee.</li> <li>Bond paper.</li> </ol> So the tags I want are opening <ol type="1"> closing tag </ol>. Here is the regex im using. $regex='<%ol type="1"%[^>]*>(.*?)</%ol%>'; preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER); return $result = $result[0]; Which is giving me the error .... Warning: preg_match_all() [function.preg-match-all]: Unknown modifier ']' The error points to the preg_match_all line, which makes me believe its the regex itself. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
effigy Posted March 4, 2008 Share Posted March 4, 2008 Why the %s? Every PREG pattern requires delimiters. The format is delimiter pattern delimiter modifiers, e.g., /abc/i. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.