Jump to content

effigy

Staff Alumni
  • Posts

    3,600
  • Joined

  • Last visited

    Never

Everything posted by effigy

  1. If you're not planning to parse the entities into characters: /(?<![\p{L}<]|<)$word(?![\p{L}>]|>)/u
  2. FYI: You can use \D for this also.
  3. Quantifiers are greedy by default; make the quantifier lazy (example) or the condition more specific: ~<object.*src="([^"]+)".*</object>~is.
  4. Pairs? <pre> <?php $data = <<<DATA <this> is a </tag> about something like <br /> or <a href="site.com">site.com</a> <img/> <a href="http://site.com">Google.com</a> <br /> <meta tag="" /> <input type="text" /> DATA; preg_match_all('%<(\w+)[^>]*>.*?</\1>%is', $data, $matches); print_r($matches); ?> </pre>
  5. What about this? I realize it's not exactly what you're after, but it does make mention of... ...so the code may give you some ideas.
  6. <pre> <?php $data = '<img src="1.jpg" /><img src="2.jpg" alt="2" />'; echo( htmlspecialchars( preg_replace('%<img\s+((??!alt=)[^>])*?)\s*/?>%', '<img $1 alt="1" />', $data) ) ); ?> </pre>
  7. <pre> <?php $data = <<<DATA <h3 class="customize">title</h3> <p class="customize">content</p> <p class="post-footer align-right customize"> <span class="date">date</span> </p> DATA; preg_match_all('%<(\w+)[^>]+class="(?:customize|date)">(.*?)</\1>%', $data, $result, PREG_PATTERN_ORDER); print_r($result); ?> </pre>
  8. Do you want to retain the last hyphen as your example shows? <pre> <?php $str = 'EM-SA0048-SIG_CODE-AA-ISTE-0033'; print_r(preg_split('/(?=-\d{4}$)|-(?!(?:.{4}-)?\d{4}$)/', $str)); ?> </pre>
  9. Perl's installation should have no effect on an editor saving a file. How are you running the script if it doesn't save? What editor are you using?
  10. <pre> <?php $data = <<<DATA <h3 class="customize">title</h3> <p class="customize">content</p> <p class="post-footer align-right customize"> <span class="date">date</span> </p> DATA; preg_match_all('/\sclass="(?:customize|date)">([^<]+)/', $data, $result, PREG_PATTERN_ORDER); print_r($result); ?> </pre>
  11. It doesn't save at all, or perhaps it adds a .txt extension? What messages/errors do you recieve? Do you have permission to use the directory?
  12. What is your desired data structure? You could just pull what you need via regex: use strict; use warnings; use Data::Dumper; my %tmp; my @data; while (<DATA>) { if (/^\s*-+\s*$/ && %tmp) { push @data, { %tmp }; %tmp = (); } next if ! /^\s*([^:]+):\s+(\d+)%?\s*$/; $tmp{$1} = $2; } push @data, { %tmp }; print Data::Dumper->Dump([\@data]); __DATA__ open cper Done. SP****** ** CPER100 NOV11 14:03:00 2100 INFO CDMA Performance Snapshot BSC: 0 Projected CSS ENGCAP: 56000 CAU : 36:5 59:5 ------------------------------------- Origination Attempts: 1538 Origination Successes: 1318 %Success: 85% ------------------------------------- Page Responses: 560 Termination Successes: 546 %Success: 97% ------------------------------------- Hard Handoff Attempts: 10 Hard Handoff Successes: 10 %Success: 100% ------------------------------------- Estimated CCR (wrt CSS ENGCAP): 88% $VAR1 = [ { '%Success' => '85', 'Origination Attempts' => '1538', 'Origination Successes' => '1318' }, { 'Termination Successes' => '546', '%Success' => '97', 'Page Responses' => '560' }, { '%Success' => '100', 'Hard Handoff Successes' => '10', 'Hard Handoff Attempts' => '10' }, { 'Estimated CCR (wrt CSS ENGCAP)' => '88' } ];
  13. What options did you use for mysqldump? I have this in a shell script for InnoDB: mysqldump \ -u root \ -p \ --skip-opt \ --single-transaction \ --add-drop-table \ --create-options \ --quick \ --extended-insert \ --set-charset \ --disable-keys \ $1 > $dump_file
  14. Can you simply compare them against a hash of possibilities?
  15. <pre> <?php $a = array(); $a['test']['itemvalue'] = 123; $output = '0[var]test[/var]456789'; echo preg_replace('%\[var\](.+?)\[/var\]%e', '$a["$1"]["itemvalue"]', $output); ?> </pre>
  16. <pre> <?php $str = 'hello!howare!yo!u?'; echo substr($str, 0, strpos($str, '!')); ?> </pre>
  17. You cannot work around these limitations? Try /(?!please select)/.
  18. Like this? if ( ! preg_match(...) ) { ... } Do you even need a regex?
  19. Did Moses add footnotes to the Ten Commandments, or is this another case of conflicting verses where you pick whichever one suits your case? Who was being beaten to death (threatened)? Christianity confuses me because the word is derived from "Christ," and yet the Bible seems to play the bigger role. In my opinion it seems that the Bible reigns, no matter if it conflicts with the words and actions of Christ. Therefore, I propose a split: Christianity--Those who follow Christ, but may still reference the Bible in support of Christ. Biblianity--Those who follow the Bible, with a lesser interest in Christ.
  20. Can we thereby say that all Christians who support(ed) the war are no longer such?
  21. What about the divorces of "proper" marriages that hit the court systems, which run on our tax dollars? What about domestic violence within "proper" marriages that use the law enforcement from our tax dollars? These things are taking my money, but I don't think we should abolish divorce or same-gender marriage.
  22. . will not match new lines without the /s modifier.
  23. print_r the array to see what you're working with. $bmatches is an array of arrays.
×
×
  • 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.