How to implement this substring replacement rule?
- %% is replaced with % and %x is replaced with #
which would do, for example,
abc %x def => abc # def
abc %%x def => abc %x def
abc %%%x def => abc %# def
abc %%%%x def => abc %%x def
<?php | |
... | |
'clientScript' => array( | |
'class' => 'CClientScript', | |
'packages' => array( | |
'jquery.ui' => array( | |
'basePath' => 'ext.jquery-ui-custom', | |
'js' => array( | |
'js/jquery-ui-1.8.18.custom' . (YII_DEBUG ? '' : '.min') . '.js' |
<html> | |
<head></head> | |
<body> | |
<p><a id="theajaxlink" href="xhrhandler.php?p=1&q=2">text</a></p> | |
<script type="text/javascript"> | |
(function () { | |
'use strict'; | |
var clickhandler = function (e) { | |
var $that = $(this); | |
e.preventDefault(); |
<?php | |
public function rules() { | |
return array( | |
array('a', 'needOneOf', 'or' => array('b', 'c', 'd')), | |
); | |
} | |
public function needOneOf($attr, $params) { | |
array_unshift($params['or'], $attr); |
(function ($) { | |
'use strict'; | |
/** | |
* Makes contenteditable elements within a container generate change events. | |
* | |
* When you do, e.g. $obj.editable(), all the DOM elements with attribute contenteditable | |
* that are children of the DOM element $obj will trigger a change event when their | |
* contents is edited and changed. | |
* | |
* See: http://html5demos.com/contenteditable |
#!/bin/sh | |
# What it does: | |
# - Start tmux | |
# - Divide the term window into two panes: | |
# * small lower pane that runs "sleep 60; sudo ipfw disable firewall", | |
# * large upper pane with a shell in it. | |
# | |
# Do your dangerous IPFW work in the upper pane. | |
# When done, switch to lower pane (Crtl-B, down arrow) and kill it with Ctrl-C |
How to implement this substring replacement rule?
which would do, for example,
abc %x def => abc # def
abc %%x def => abc %x def
abc %%%x def => abc %# def
abc %%%%x def => abc %%x def
<?php | |
// Some people object to this use of the ternary. I think it's fine so long as each | |
// condition-value pair fits nicely on one line. If so then the structure is highly | |
// expressive. The value $var takes is very obvious. The logic that | |
// this condition => that value, this condition => that value, etc. is plain to see. | |
$var = | |
condition1 ? 'value1' : ( | |
condition2 ? 'value2' : ( | |
condition3 ? 'value3' : ( |
<?php | |
$letnum = '\p{L}\p{Mn}\p{Mc}\p{Nd}'; | |
$sym = '+&@#/%=~_|$'; | |
$pnct = '?!:,.-'; | |
$c1 = "[$letnum$sym$pnct]"; | |
$c2 = "[$letnum$sym]"; | |
// then the regex pattern is, so to speak: | |
// \b(?: https?:// | www\. ) (?: \($c1*\) | $c1 )* (?: \($c1*\) | $c2 ) | |
// with xui options. |
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Spinitron Playlists</title> | |
</head> | |
<body> | |
<p class="recentsong"> | |
<span class="songpart"><b>Wave Guidance Allows Three</b></span> | |
<span class="artistpart">by <b><a target="_top" href="/public/index.php?station=wzbc&dbdetail=a&dbid=83733">The Swifter</a></b></span> |
<?php | |
$input = preg_replace( | |
'{& (?! \#x[\da-f]{2,6} ; ) | |
(?! \#\d{3,6} ; ) | |
(?! [a-z0-9]{2,16} ; ) | |
}xiu', | |
'&', | |
$input | |
); |