Jump to content

effigy

Staff Alumni
  • Posts

    3,600
  • Joined

  • Last visited

    Never

Everything posted by effigy

  1. <pre> <?php $data = <<<DATA rat pig bear rat pig bear rat pig bear rat cat dog rat pig bear rat pig bear rat cat monkey rat pig bear rat pig bear DATA; preg_match_all('/(?<=\scat\s).+$/m', $data, $matches); print_r($matches); ?> </pre>
  2. Agreed on both points. How are Denmark's politics in comparison?
  3. Daniel: I see your point; however, how many people: bother looking outside of the Democrat/Republican realm are aware that there are more (realistic) choices prior to seeing the ballot do not rely solely on the TV for getting their information Frankly, many of the people I've encountered know next to nothing about other parties (myself often included!). If the debates were open, the media not Democratic- and Republican-centric, etc., people would actually know something about them, and perhaps just enough to make them think down a different path, thus, opening up possibilities. After all, I thought that's what America is supposed to be about. Crayon: Are you an anarchist by chance? What solution do you propose againt these evils?
  4. Use explode for this level of simplicity.
  5. What about the rest of the "evils"? There were 7 presidential candidates on my ballot. Okay let me amend that to "Lesser of the $x evils." So you were well-informed on every single candidate running, enough to deem them all "evil"?
  6. IL: Barack Obama/Joe Biden Cynthia McKinney/Rosa Clemente John McCain/Sarah Palin Bob Barr/Wayne A. Root John Joseph Polachek/No Candidate Charles O. Baldwin/Darrell L. Castle Ralph Nader/Matt Gonzalez
  7. What about the rest of the "evils"? There were 7 presidential candidates on my ballot.
  8. I would use /(?:\s+Qualifying)?\s+Round.*/.
  9. <pre> <?php $cups = array( 'FA Cup', 'FA Cup Qualifying Round 1', 'FA Cup Qualifying Round 2', 'FA Cup Qualifying Round 3', 'FA Cup Round 1', 'FA Cup Round 2', 'Carling Cup', 'Carling Cup Round 1', 'Carling Cup Round 2', ); $seen = array(); foreach ($cups as $cup) { $cup = preg_replace('/(?<=\bCup)\b.+$/', '', $cup); if (array_key_exists($cup, $seen)) { continue; } $seen[$cup] = null; echo $cup, "\n"; } ?> </pre>
  10. Some tips: [*]Change your delimiters to avoid multiple escapes [*]When using literal data inside of a pattern, always escape it using preg_quote [*]Use character classes in place of one character alternations, e.g., (a|b|c) I suspect the second bullet may alleviate your problem.
  11. <pre> <?php $subject = 'The cat sat on the [[straw|mat]]. The cat hoped he would jump through the [[windows]] and catch the [[feathered variety|bird on the branch]].'; preg_match_all( '%\[\[(?:[^]|]+\|)?([^]]+)\]\]%', $subject, $matches ); $matches = $matches[1]; print_r($matches); ?> </pre>
  12. %\\\\\\\% First you have to consider PHP's escaping rules, then the regex rules, which results in a double escaping effect.
  13. How about something like this? <pre> <?php $data = <<<DATA \$my_array = array( 'key' => "value", 'another_key' => 'another_value' ); DATA; preg_match_all('/^\s*(\$\S+\s*=\s*array\(.*?\);)/ms', $data, $matches); array_shift($matches); print_r($matches); foreach ($matches[0] as &$match) { preg_match('/^\s*\$(\S+)/', $match, $name); eval('$array = ' . $match); $result[$name[1]] = $array; } print_r($result); ?> </pre>
  14. <?php $data = <<<DATA I dont understand a little about RegEx but cannot really understand how to use all the funtions . I need to convert link tag <a href ....> that DOES NOT already have the css in them. Such as <a href="http://www.google.com" style="font-size: 11px;" other properties> should NOT matched but <a href="http://www.google.com" .. other properties> should match and a style="..." should be added. DATA; echo htmlspecialchars(preg_replace('/<a((??!style=)[^>])+)>/', '<a style="xyz" $1>', $data)); ?>
  15. Your meta is commented out, so it may be relying on the browser, server, or file. Is there any meta information in the included files? When you save them, are there any encoding options?
  16. What's in your meta tag(s)? Are both files saved as Latin-1?
  17. Sanitize the words with preg_quote.
  18. It should be fine without the concatenation. Do you have an example of it failing?
  19. If you want to match e-mail addresses to a tee, see the RFC.
  20. There's no point in capturing more than you need: echo $result = preg_replace('/^.*\.\s+/m', '', $data);
  21. Shorthands are not available in EREG; use PREG. Also, why the \s? <pre> <?php function valid_propadd($pa) { return preg_match('/(?:\w\s?)+/', $pa); } $tests = array( '120_Ho_St', '120_Howe_St', ); foreach ($tests as $test) { echo $test, ' => ', valid_propadd($test) ? 'Valid' : 'Invalid' ; echo '<br>'; } ?> </pre>
  22. Is Perl an option? I would array this, if not as an end result, at least in the manner of XML->array->parse->XML.
  23. ucfirst(strtolower("Name"));
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.