<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>softelメモ</title>
	<atom:link href="http://www.softel.co.jp/blogs/tech/feed" rel="self" type="application/rss+xml" />
	<link>http://www.softel.co.jp/blogs/tech</link>
	<description>システム開発 ソフテルの技術関連ブログ（php、Linux、Apache、MySQL、その他開発関連）</description>
	<lastBuildDate>Mon, 06 Feb 2012 00:45:55 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>【Javascript】正規表現でgフラグを付けても phpのpreg_match_all()のようなことができない</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2972</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2972#comments</comments>
		<pubDate>Sun, 05 Feb 2012 20:57:32 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2972</guid>
		<description><![CDATA[問題 これで、abc,def,ghi が取れないんだけど。 "123abc456def789ghi".match(/\d+([a-z]+)/g); phpのpreg_match_all()などだと、マッチした文字列も、キャプチャした文字列も、どこかでまとめて取れるけど、Javascriptだと無理？ 答え まず、Javascriptの正規表現のmatch()はgフラグをつけているかどうかで戻り値が違う。 &#8220;123abc456def789ghi&#8221;.match(/\d+([a-z]+)/g); → &#8220;123abc&#8221;,&#8221;456def&#8221;,&#8221;789ghi&#8221; 　（1回目適用、2回目適用、3回目適用、……） &#8220;123abc456def789ghi&#8221;.match(/\d+([a-z]+)/); → &#8220;123abc&#8221;,&#8221;abc&#8221; 　（1回目適用、キャプチャされたもの1、キャプチャされたもの2、キャプチャされたもの3、……） String.match だとこれ以上どうしようもないので、 正規表現で &#8220;g&#8221; フラグを使用する場合、同じ文字列で成功するマッチを見つけるために exec メソッドを複数回使うことができます。 という RegExp.execを使ってみると、「次のマッチが始まる位置（lastIndex）」を確認しながら、ループする形になる。 var myRe=/\d+([a-z]+)/g; var str = "123abc456def789ghi"; var myArray; while ((myArray = myRe.exec(str)) != null) { var msg = myArray.shift() + " を見つけました。"; msg += "キャプチャされたのは " + myArray + " です。"; [...]]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>これで、abc,def,ghi が取れないんだけど。</p>
<pre class="bash">"123abc456def789ghi".match(/\d+([a-z]+)/g);</pre>
<p>phpのpreg_match_all()などだと、マッチした文字列も、キャプチャした文字列も、どこかでまとめて取れるけど、Javascriptだと無理？</p>
<h3>答え</h3>
<p>まず、Javascriptの正規表現のmatch()はgフラグをつけているかどうかで戻り値が違う。</p>
<p>&#8220;123abc456def789ghi&#8221;.match(/\d+([a-z]+)/g);<br />
→ &#8220;123abc&#8221;,&#8221;456def&#8221;,&#8221;789ghi&#8221;<br />
　（1回目適用、2回目適用、3回目適用、……）</p>
<p>&#8220;123abc456def789ghi&#8221;.match(/\d+([a-z]+)/);<br />
→ &#8220;123abc&#8221;,&#8221;abc&#8221;<br />
　（1回目適用、キャプチャされたもの1、キャプチャされたもの2、キャプチャされたもの3、……）</p>
<p>String.match だとこれ以上どうしようもないので、</p>
<blockquote><p>正規表現で &#8220;g&#8221; フラグを使用する場合、同じ文字列で成功するマッチを見つけるために exec メソッドを複数回使うことができます。</p></blockquote>
<p>という RegExp.execを使ってみると、「次のマッチが始まる位置（lastIndex）」を確認しながら、ループする形になる。</p>
<pre class="bash">
var myRe=/\d+([a-z]+)/g;
var str = "123abc456def789ghi";
var myArray;
while ((myArray = myRe.exec(str)) != null) {
    var msg = myArray.shift() + " を見つけました。";
    msg += "キャプチャされたのは " + myArray + " です。";
    msg += "次のマッチは " + myRe.lastIndex + " からです。";
    alert(msg);
}
</pre>
<p>Javascriptでの上の例を見ると、phpのpreg_match_all()関数は、本来は上のようになるところを、めんどくさくないようにしてくれている便利機能なんだなと考えることができそうです。</p>
<h4>補足</h4>
<p>もっと簡単にabc,def,ghiを取るには、&#8217;123abc456def789ghi&#8217;全体にマッチする正規表現を作って、その中でabc,def,ghiをキャプチャできるようにする。</p>
<pre class="bash">
//キャプチャしたかったらこうなるか……もっとよい書き方がある？

"123abc456def789ghi".match(/\d+([a-z]+)\d+([a-z]+)\d+([a-z]+)/);

//→ キャプチャされるのは"abc","def","ghi"</pre>
<pre class="bash">
//キャプチャ用パターンを繰り返したとき
//キャプチャされるのは繰り返しの最後でマッチした部分文字列なので

"123abc456def789ghi".match(/(\d+([a-z]+))+/g);

//→ 文字列全体がマッチするのは期待通りだが、キャプチャされるのは"789ghi","ghi"だけ

//置換などで何が何番目のキャプチャかわからないと「\何番目」と書くとき困るから仕方ないか</pre>
<h3>参考</h3>
<p><a href="https://developer.mozilla.org/ja/Core_JavaScript_1.5_Reference/Global_Objects/RegExp/exec">https://developer.mozilla.org/ja/Core_JavaScript_1.5_Reference/Global_Objects/RegExp/exec</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2972/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>【windows】リモートデスクトップの接続数に+1（コンソール・セッション）</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/826</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/826#comments</comments>
		<pubDate>Sat, 04 Feb 2012 22:56:42 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=826</guid>
		<description><![CDATA[リモート・デスクトップ接続には、コンソール・セッションとリモート・セッションの2つがある。 リモートデスクトップでは通常はリモート・セッション。 %windir%\system32\mstsc.exe コンソール・セッションは /admin を引数に追加してリモートデスクトップする。 （%windir%\system32\mstsc.exe /console の環境もあり） %windir%\system32\mstsc.exe /admin Windows Server 2003／Windows Server 2008 のリモートデスクトップでは2人までしか入れないかと思っていたら、リモート・セッションが2接続で、もうひとつコンソール・セッションの1接続が使えるとのこと。 リモート・セッションはそれぞれの接続が独立しているので、2人が接続してもそれぞれにそれぞれのデスクトップがある状態となる。 コンソール・セッションとは実機の実ログインに相当する。実機の前で作業していて、何らかの事情で離れたところから作業を継続するとき、逆に離れたところで作業をしていて、続きは実機の前でおこなう場合などに使える。]]></description>
			<content:encoded><![CDATA[<p>リモート・デスクトップ接続には、コンソール・セッションとリモート・セッションの2つがある。</p>
<p>リモートデスクトップでは通常はリモート・セッション。</p>
<pre class="bash">%windir%\system32\mstsc.exe</pre>
<p>コンソール・セッションは /admin を引数に追加してリモートデスクトップする。<br />
（%windir%\system32\mstsc.exe /console の環境もあり）</p>
<pre class="bash">%windir%\system32\mstsc.exe /admin</pre>
<p>Windows Server 2003／Windows Server 2008 のリモートデスクトップでは2人までしか入れないかと思っていたら、リモート・セッションが2接続で、もうひとつコンソール・セッションの1接続が使えるとのこと。</p>
<p>リモート・セッションはそれぞれの接続が独立しているので、2人が接続してもそれぞれにそれぞれのデスクトップがある状態となる。</p>
<p>コンソール・セッションとは実機の実ログインに相当する。実機の前で作業していて、何らかの事情で離れたところから作業を継続するとき、逆に離れたところで作業をしていて、続きは実機の前でおこなう場合などに使える。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/826/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【Javascript】jQueryだけでタブ切り替えの例（また）</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2958</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2958#comments</comments>
		<pubDate>Fri, 03 Feb 2012 19:47:11 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2958</guid>
		<description><![CDATA[問題 jQueryだけで、タブっぽいの、たのむ。 解答例 jquery.ui や twitter bootstrap を使えば、美しいタブ切り替えをあっという間に作成可能です。 ただ、比較的よく検索にヒットしている以前書いたこれの内容が古いので、改めてjqueryだけでタブ切り替え風の動きをさせてみます。 出来合いのライブラリを使うと、うまくデザインを変更できなくて困っているときにもどうぞ。 改善点 タブが増えるとスクリプトも変更して増やす必要のある作戦を考え直す。 今は event.preventDefault()なんて使わなくていい。 ソースサンプル &#60;!DOCTYPE html&#62; &#60;html&#62; &#60;head&#62; &#60;meta charset="utf-8"&#62; &#60;title&#62;jQueryだけでタブ切り替えサンプル 2&#60;/title&#62; &#60;style type="text/css"&#62; /* タブっぽく並べて */ #tabs ul {overflow:hidden; height:2em; list-style:none; border-bottom:1px solid #cccccc;} #tabs li {float:left; display:inline; margin-left:10px; padding:5px; border:1px solid #ccc; border-bottom:none; border-radius:10px 10px 0 0;} /* 最初はパネルは非表示 */ #tabs .panel [...]]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>jQueryだけで、タブっぽいの、たのむ。</p>
<h3>解答例</h3>
<p><a href="http://jqueryui.com/">jquery.ui</a> や <a href="http://twitter.github.com/bootstrap/">twitter bootstrap</a> を使えば、美しいタブ切り替えをあっという間に作成可能です。</p>
<p>ただ、比較的よく検索にヒットしている<a href="http://www.softel.co.jp/blogs/tech/archives/1564">以前書いたこれ</a>の内容が古いので、改めて<a href="http://jquery.com/">jquery</a>だけでタブ切り替え風の動きをさせてみます。</p>
<p>出来合いのライブラリを使うと、うまくデザインを変更できなくて困っているときにもどうぞ。</p>
<h4>改善点</h4>
<ul>
<li>タブが増えるとスクリプトも変更して増やす必要のある作戦を考え直す。</li>
<li>今は event.preventDefault()なんて使わなくていい。</li>
</ul>
<h4>ソースサンプル</h4>
<pre class="brush:html;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;jQueryだけでタブ切り替えサンプル 2&lt;/title&gt;
&lt;style type="text/css"&gt;
	/* タブっぽく並べて */
	#tabs ul {overflow:hidden; height:2em; list-style:none; border-bottom:1px solid #cccccc;}
	#tabs li {float:left; display:inline; margin-left:10px; padding:5px; border:1px solid #ccc; border-bottom:none; border-radius:10px 10px 0 0;}
	/* 最初はパネルは非表示 */
	#tabs .panel {display:none;}
&lt;/style&gt;
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(function() {
	/**
	 * それぞれのタブをクリックしたとき開きたい要素がどれになるかはHTMLの方に書くようにしたので、Javascriptの方は1行でよい
	 * id="tabs"の中のhrefが#panel何々となっているa要素をクリックすると
	 * classがpanelとなっているdivを全部非表示にして、クリックしたタブのハッシュと同じIDの要素だけをフェードインして表示
	 * return false で onclick="return false" と同様にデフォルトのイベント処理は抑制
	 */
	$('#tabs a[href^="#panel"]').click(function(){
		$("#tabs .panel").hide();
		$(this.hash).fadeIn();
		return false;
	});
	//わざと1つ目を表示させておくことができます
	$('#tabs a[href^="#panel"]:eq(0)').trigger('click');
})
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;jQueryだけでタブ切り替えサンプル&lt;/h1&gt;
&lt;div id="tabs"&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href="#panel1"&gt;お知らせ&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#panel2"&gt;ご利用方法&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#panel3"&gt;利用規約&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="mailto:test&amp;#64;example.com"&gt;お問い合わせ&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="#panel4"&gt;運営会社&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;

	&lt;div id="panel1" class="panel"&gt;
		&lt;p&gt;1つ目のタブの内容。&lt;/p&gt;
		&lt;p&gt;1つ目のタブの内容。&lt;/p&gt;
	&lt;/div&gt;

	&lt;div id="panel2" class="panel"&gt;
		&lt;p&gt;2つ目のタブの内容。&lt;/p&gt;
		&lt;p&gt;2つ目のタブの内容。&lt;/p&gt;
	&lt;/div&gt;

	&lt;div id="panel3" class="panel"&gt;
		&lt;p&gt;3つ目のタブの内容。&lt;/p&gt;
		&lt;p&gt;3つ目のタブの内容。&lt;/p&gt;
	&lt;/div&gt;

	&lt;div id="panel4" class="panel"&gt;
		&lt;p&gt;4つ目のタブの内容。&lt;/p&gt;
		&lt;p&gt;4つ目のタブの内容。&lt;/p&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h4>デモ</h4>
<style type="text/css">
	#tabs ul {overflow:hidden; height:2em; list-style:none; border-bottom:1px solid #cccccc;}
	#tabs li {float:left; display:inline; margin-left:10px; padding:5px; border:1px solid #ccc; border-bottom:none; border-radius:10px 10px 0 0;}
	#tabs .panel {display:none;}
</style>
<p><script type="text/javascript">
$(function() {
	$('#tabs a[href^="#panel"]').click(function(){
		$("#tabs .panel").hide();
		$(this.hash).fadeIn();
		return false;
	});
	$('#tabs a[href^="#panel"]:eq(0)').trigger('click');
});
</script></p>
<div id="tabs">
<ul>
<li><a href="#panel1">お知らせ</a></li>
<li><a href="#panel2">ご利用方法</a></li>
<li><a href="#panel3">利用規約</a></li>
<li><a href="mailto:test&#64;example.com">お問い合わせ</a></li>
<li><a href="#panel4">運営会社</a></li>
</ul>
<div id="panel1" class="panel">
<p>普通のタブ切り替えサンプルです。 普通のタブ切り替えサンプルです。 </p>
<p>普通のタブ切り替えサンプルです。 普通のタブ切り替えサンプルです。 </p>
<p>普通のタブ切り替えサンプルです。 普通のタブ切り替えサンプルです。 </p>
</p></div>
<div id="panel2" class="panel">
<p>順番や配置の位置関係には特にルールがありません。</p>
<p>タブの方にどのパネルを開くか書いてあるので、Javascriptはそれに従うだけです。</p>
<p>順番や配置の位置関係には特にルールがありません。</p>
<p>タブの方にどのパネルを開くか書いてあるので、Javascriptはそれに従うだけです。</p>
</p></div>
<div id="panel3" class="panel">
<p>タブの中にメール送信など変わったアクションが混ざっていても大丈夫です。</p>
<p>タブの中にメール送信など変わったアクションが混ざっていても大丈夫です。</p>
<p>4つ目のタブのa要素は、mailto:でメールソフト起動のリンクになっていますが、それはそのように動きます。</p>
</p></div>
<div id="panel4" class="panel">
<p>デザインに関しても、ほぼ作成者の自由です。</p>
<p>タブ部分に角丸CSSを指定してみたりしました。</p>
<p>Javascriptでは、タブのa要素をクリックすると、関連するdiv要素を表示することをしているだけです。</p>
<p>CSSはいくら変えても大丈夫です。</p>
</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2958/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【Javascript】文字列を末尾から1文字ずつ削りながらループする</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2956</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2956#comments</comments>
		<pubDate>Fri, 03 Feb 2012 09:36:12 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2956</guid>
		<description><![CDATA[問題 文字列を末尾から1文字ずつ削りながらループせよ。 解答例 文字列は、今見ているページのURLを使ってループしてみる。 for (var s = location.pathname; s != ''; s = s.slice(0, -1)) { alert(s); } 実行してみたいときはこちらをクリック →]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>文字列を末尾から1文字ずつ削りながらループせよ。</p>
<h3>解答例</h3>
<p>文字列は、今見ているページのURLを使ってループしてみる。</p>
<pre class="bash" id="sample20120203">
for (var s = location.pathname; s != ''; s = s.slice(0, -1)) {
    alert(s);
}
</pre>
<p>実行してみたいときはこちらをクリック → <input type="button" value="eval" onclick="eval($('#sample20120203').html());"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2956/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【wkhtmltopdf】ヘッダに「ページ数/総ページ数」を挿入する</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2952</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2952#comments</comments>
		<pubDate>Thu, 02 Feb 2012 09:16:53 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[develop]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2952</guid>
		<description><![CDATA[問題 帳票印刷にwkhtmltopdfを使っています。 「何ページ中何ページ目」をヘッダに入れたいです。 答え ページ数などすべてHTMLに書き込んでからコマンドに渡してもよいが、ずるずると続く文書がいったいどこで改ページされるのか不明な場合など、改ページの制御が難しい場合もある。 そこで、wkhtmltopdfにヘッダを生成してもらう例を書いておく。 ヘッダ挿入の機能の概要 コマンドオプション --header-html に指定したHTMLがヘッダに挿入される。フッタも --footer-html に指定できる。 その際、引数が渡されて、今何ページ目なのか、今何章目なのかなどが取得できる。 wkhtmltopdfはwebkitでHTMLをレンダリングするのだが、Javascriptを実行してその結果のHTMLをPDFにできてしまう。ヘッダのページ数などはJavascriptにお任せする。 下の一覧は渡してもらえる引数の一覧。 * [page] Replaced by the number of the pages currently being printed * [frompage] Replaced by the number of the first page to be printed * [topage] Replaced by the number of the last page to be printed * [webpage] [...]]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>帳票印刷にwkhtmltopdfを使っています。</p>
<p>「何ページ中何ページ目」をヘッダに入れたいです。</p>
<h3>答え</h3>
<p>ページ数などすべてHTMLに書き込んでからコマンドに渡してもよいが、ずるずると続く文書がいったいどこで改ページされるのか不明な場合など、改ページの制御が難しい場合もある。</p>
<p>そこで、wkhtmltopdfにヘッダを生成してもらう例を書いておく。</p>
<h4>ヘッダ挿入の機能の概要</h4>
<p>コマンドオプション <code>--header-html</code> に指定したHTMLがヘッダに挿入される。フッタも <code>--footer-html</code> に指定できる。</p>
<p>その際、引数が渡されて、今何ページ目なのか、今何章目なのかなどが取得できる。</p>
<p>wkhtmltopdfはwebkitでHTMLをレンダリングするのだが、Javascriptを実行してその結果のHTMLをPDFにできてしまう。ヘッダのページ数などはJavascriptにお任せする。</p>
<p>下の一覧は渡してもらえる引数の一覧。</p>
<blockquote><p>
 * [page]       Replaced by the number of the pages currently being printed<br />
 * [frompage]   Replaced by the number of the first page to be printed<br />
 * [topage]     Replaced by the number of the last page to be printed<br />
 * [webpage]    Replaced by the URL of the page being printed<br />
 * [section]    Replaced by the name of the current section<br />
 * [subsection] Replaced by the name of the current subsection<br />
 * [date]       Replaced by the current date in system local format<br />
 * [time]       Replaced by the current time in system local format
</p></blockquote>
<h4>ヘッダ用のHTMLを用意する</h4>
<p>渡された引数を利用して、Javascriptでヘッダを生成する。ヘッダ用のHTMLを用意して、その中にJaavscriptを書く。</p>
<p>下は例。</p>
<pre class="bash">
&lt;html&gt;&lt;head&gt;&lt;script&gt;
function subst() {
	var vars={};
	var x=document.location.search.substring(1).split('&amp;');
	for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
	var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
	for(var i in x) {
		var y = document.getElementsByClassName(x[i]);
		for(var j=0; j&lt;y.length; ++j) y[j].textContent = vars[x[i]];
	}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body style="border:0; margin: 0;" onload="subst()"&gt;
&lt;table style="border-bottom: 1px solid black; width: 100%"&gt;
	&lt;tr&gt;
		&lt;td class="section"&gt;&lt;/td&gt;
		&lt;td style="text-align:right"&gt;
		Page &lt;span class="page"&gt;&lt;/span&gt; of &lt;span class="topage"&gt;&lt;/span&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h4>以下のようなHTMLを用意してみる</h4>
<p>わざと改ページを入れて複数ページになるようにした。</p>
<pre class="bash">
&lt;html&gt;
&lt;head&gt;
	&lt;meta charset="UTF-8"&gt;
	&lt;title&gt;example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
	&lt;p&gt;例の1ページ目&lt;/p&gt;
&lt;/div&gt;
&lt;hr style="page-break-after:always;"&gt;

&lt;div&gt;
	&lt;p&gt;例の2ページ目&lt;/p&gt;
&lt;/div&gt;
&lt;hr style="page-break-after:always;"&gt;

&lt;div&gt;
	&lt;p&gt;例の3ページ目&lt;/p&gt;
&lt;/div&gt;
&lt;hr style="page-break-after:always;"&gt;

&lt;div&gt;
	&lt;p&gt;例の4ページ目&lt;/p&gt;
&lt;/div&gt;
&lt;hr style="page-break-after:always;"&gt;

&lt;div&gt;
	&lt;p&gt;例の5ページ目&lt;/p&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h4>ヘッダ用HTMLをコマンドオプションに指定してwkhtmltopdfする</h4>
<p>ここまでの材料を、それぞれ header.html や example.html などの名前で保存しておき、以下のコマンドを実行。</p>
<pre class="bash">$ wkhtmltopdf --header-html header.html example.html example.pdf</pre>
<p>（example.htmlをexample.pdfにする。ヘッダにheader.htmlを挿入する。）</p>
<h4>出来上がり</h4>
<p><img src="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/02/test.pdf.png" alt="" title="test.pdf" width="595" height="500" class="alignnone size-full wp-image-2953" /></p>
<p><a href='http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/02/example.pdf'>実行結果PDF ダウンロード</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2952/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【Windows】shell:コマンド</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2740</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2740#comments</comments>
		<pubDate>Wed, 01 Feb 2012 00:00:00 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2740</guid>
		<description><![CDATA[shellコマンドは、通常どこにあるのかよくわからない場所（お気に入り、右クリックの&#8221;送る&#8221;、クイック起動など）にすばやくアクセスするのにとても便利です。 ショートカットを作るときやコマンドラインから実行するときは、以下のように explorer.exe の引数にするとよいです。 explorer.exe shell:SendTo ファイル名を指定して実行（Windowsキー+R）をするときは、以下のように、shell:コマンドのみでよいです。 Windows 7 のみ shell:Libraries shell:MusicLibrary shell:VideosLibrary shell:OtherUsersFolder shell:Device Metadata Store shell:PublicSuggestedLocations shell:DocumentsLibrary shell:User Pinned shell:UsersLibrariesFolder shell:PicturesLibrary shell:ImplicitAppShortcuts shell:Ringtones shell:CommonRingtones Windows Vista と Windows 7 shell:Common Programs shell:GameTasks shell:UserProfiles shell:MyComputerFolder shell:SyncSetupFolder shell:DpapiKeys shell:SamplePlaylists shell:Favorites shell:My Video shell:SearchHomeFolder shell:System shell:CommonVideo shell:SyncResultsFolder shell:LocalizedResourcesDir shell:Cookies shell:Original Images shell:CommonMusic shell:My Pictures shell:Cache shell:Downloads [...]]]></description>
			<content:encoded><![CDATA[<p>shellコマンドは、通常どこにあるのかよくわからない場所（お気に入り、右クリックの&#8221;送る&#8221;、クイック起動など）にすばやくアクセスするのにとても便利です。</p>
<p>ショートカットを作るときやコマンドラインから実行するときは、以下のように explorer.exe の引数にするとよいです。</p>
<pre class="bash">explorer.exe shell:SendTo</pre>
<p>ファイル名を指定して実行（Windowsキー+R）をするときは、以下のように、shell:コマンドのみでよいです。</p>
<p><a href="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/02/shell-command.png"><img src="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/02/shell-command.png" alt="" title="shell-command" width="423" height="252" class="alignnone size-full wp-image-2949" /></a></p>
<h4>Windows 7 のみ</h4>
<p>shell:Libraries<br />
shell:MusicLibrary<br />
shell:VideosLibrary<br />
shell:OtherUsersFolder<br />
shell:Device Metadata Store<br />
shell:PublicSuggestedLocations<br />
shell:DocumentsLibrary<br />
shell:User Pinned<br />
shell:UsersLibrariesFolder<br />
shell:PicturesLibrary<br />
shell:ImplicitAppShortcuts<br />
shell:Ringtones<br />
shell:CommonRingtones</p>
<h4>Windows Vista と Windows 7</h4>
<p>shell:Common Programs<br />
shell:GameTasks<br />
shell:UserProfiles<br />
shell:MyComputerFolder<br />
shell:SyncSetupFolder<br />
shell:DpapiKeys<br />
shell:SamplePlaylists<br />
shell:Favorites<br />
shell:My Video<br />
shell:SearchHomeFolder<br />
shell:System<br />
shell:CommonVideo<br />
shell:SyncResultsFolder<br />
shell:LocalizedResourcesDir<br />
shell:Cookies<br />
shell:Original Images<br />
shell:CommonMusic<br />
shell:My Pictures<br />
shell:Cache<br />
shell:Downloads<br />
shell:CommonDownloads<br />
shell:AppData<br />
shell:SyncCenterFolder<br />
shell:My Music<br />
shell:ConflictFolder<br />
shell:SavedGames<br />
shell:InternetFolder<br />
shell:Quick Launch<br />
shell:SystemCertificates<br />
shell:Contacts<br />
shell:TreePropertiesFolder<br />
shell:Profile<br />
shell:Start Menu<br />
shell:Common AppData<br />
shell:PhotoAlbums<br />
shell:ConnectionsFolder<br />
shell:Administrative Tools<br />
shell:PrintersFolder<br />
shell:Default Gadgets<br />
shell:ProgramFilesX86<br />
shell:Searches<br />
shell:Common Startup<br />
shell:ControlPanelFolder<br />
shell:SampleVideos<br />
shell:SendTo<br />
shell:ResourceDir<br />
shell:ProgramFiles<br />
shell:CredentialManager<br />
shell:PrintHood<br />
shell:MAPIFolder<br />
shell:CD Burning<br />
shell:AppUpdatesFolder<br />
shell:Common Start Menu<br />
shell:LocalAppDataLow<br />
shell:Templates<br />
shell:Gadgets<br />
shell:Programs<br />
shell:Recent<br />
shell:SampleMusic<br />
shell:Desktop<br />
shell:CommonPictures<br />
shell:RecycleBinFolder<br />
shell:CryptoKeys<br />
shell:Common Templates<br />
shell:Startup<br />
shell:Links<br />
shell:OEM Links<br />
shell:SamplePictures<br />
shell:Common Desktop<br />
shell:NetHood<br />
shell:Games<br />
shell:Common Administrative Tools<br />
shell:NetworkPlacesFolder<br />
shell:SystemX86<br />
shell:History<br />
shell:AddNewProgramsFolder<br />
shell:Playlists<br />
shell:ProgramFilesCommonX86<br />
shell:PublicGameTasks<br />
shell:ChangeRemoveProgramsFolder<br />
shell:Public<br />
shell:Common Documents<br />
shell:CSCFolder<br />
shell:Local AppData<br />
shell:Windows<br />
shell:UsersFilesFolder<br />
shell:ProgramFilesCommon<br />
shell:Fonts<br />
shell:Personal</p>
<h3>参考</h3>
<p><a href="http://www.osattack.com/windows-7/huge-list-of-windows-7-shell-commands/">http://www.osattack.com/windows-7/huge-list-of-windows-7-shell-commands/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2740/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【MySQL】 Got error 139 from storage engine → text, blobのカラムが多すぎ</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2580</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2580#comments</comments>
		<pubDate>Mon, 30 Jan 2012 23:59:48 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2580</guid>
		<description><![CDATA[問題 MySQLでSQLを実行したら、こんなエラーが返ってきた。 Got error 139 from storage engine これは何？ 答え 参考： InnoDBテーブル上の制約 VARCHAR、BLOB そして TEXT カラム以外の最大行長は、データベース ページの半分よりも少し短いです。 これは、最大行長は約8000バイトであるという事です。 （中略） InnoDB が行内の VARCHAR、BLOB、または TEXT カラムの最初の768バイトを格納し、残りは別のページに格納されます。 InnoDBの行サイズの上限はページサイズの約半分で、デフォルトでページサイズは16KBなので、デフォルトでは約8000バイト（変更したいときは再コンパイル）。 可変長カラム(VARBINARY, VARCHAR, BLOB, TEXT)のデータは行の外部に保存されるが、先頭の768バイトは行の内部に保存される。 そのため、ひとつのテーブルにTEXT型のカラムを10個作ると、運がよければ（他にカラムが少なければ）、1レコード8000バイトに収まることが多く、問題に気づかないこともある。 ひとつのテーブルに11個のTEXT型フィールドを作り、それぞれに768バイト以上のデータを入れようとすると、768*11=8448 > 8000 なので保存できない。 このときのエラーが Got error 139 from storage engine なお、InnoDBでなくてもよい場合では、テーブルをMyISAMに変換することで回避できる。 ALTER TABLE TABLE_NAME ENGINE=MyISAM; データタイプが必要とする記憶容量によると、「MyISAM テーブル内の行の最大サイズは65,534バイトです。BLOB と TEXT カラムはそれぞれ、このサイズに対してたった5から9バイトを占めています。」ので、同様の問題が発生することはほぼない。]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>MySQLでSQLを実行したら、こんなエラーが返ってきた。</p>
<pre class="bash">Got error 139 from storage engine</pre>
<p>これは何？</p>
<h4>答え</h4>
<p>参考： <a href="http://dev.mysql.com/doc/refman/5.1/ja/innodb-restrictions.html">InnoDBテーブル上の制約</a></p>
<blockquote>
<p>VARCHAR、BLOB そして TEXT カラム以外の最大行長は、データベース ページの半分よりも少し短いです。</p>
<p>これは、最大行長は約8000バイトであるという事です。</p>
<p>（中略）</p>
<p>InnoDB が行内の VARCHAR、BLOB、または TEXT カラムの最初の768バイトを格納し、残りは別のページに格納されます。</p>
</blockquote>
<p>InnoDBの行サイズの上限はページサイズの約半分で、デフォルトでページサイズは16KBなので、デフォルトでは約8000バイト（変更したいときは再コンパイル）。</p>
<p>可変長カラム(VARBINARY, VARCHAR, BLOB, TEXT)のデータは行の外部に保存されるが、先頭の768バイトは行の内部に保存される。</p>
<p>そのため、ひとつのテーブルにTEXT型のカラムを10個作ると、運がよければ（他にカラムが少なければ）、1レコード8000バイトに収まることが多く、問題に気づかないこともある。</p>
<p>ひとつのテーブルに11個のTEXT型フィールドを作り、それぞれに768バイト以上のデータを入れようとすると、768*11=8448 > 8000 なので保存できない。</p>
<p>このときのエラーが</p>
<pre class="bash">Got error 139 from storage engine</pre>
<p>なお、InnoDBでなくてもよい場合では、テーブルをMyISAMに変換することで回避できる。</p>
<pre class="bash">ALTER TABLE TABLE_NAME ENGINE=MyISAM;</pre>
<p><a href="http://dev.mysql.com/doc/refman/5.1/ja/storage-requirements.html">データタイプが必要とする記憶容量</a>によると、「MyISAM テーブル内の行の最大サイズは65,534バイトです。BLOB と TEXT カラムはそれぞれ、このサイズに対してたった5から9バイトを占めています。」ので、同様の問題が発生することはほぼない。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2580/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【teraterm】ダブルクリックするだけでサーバーにログインできるショートカットを作る</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2946</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2946#comments</comments>
		<pubDate>Mon, 30 Jan 2012 09:47:56 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[develop]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2946</guid>
		<description><![CDATA[問題 なにげに、sshでサーバーにログインする手間って、大きいんだけど、簡単にならない？ サーバー選んで、場合によってはポートを指定して、パスワード入力したり、鍵ファイル指定したり…… 答え teratermでは、コマンドオプションにひととおり指定ができるので、起動するだけでサーバーにSSHで接続するショートカットを作ることができる。 コマンドラインオプションの説明にしたがって、 以下のような形で、ホストもパスワードも特別に設定したポートも鍵ファイルも持たせておくことができる。 C:\teraterm\ttermpro.exe 192.168.123.123:23456 /auth=password /user=testuser /passwd=testpass C:\teraterm\ttermpro.exe testuser@192.168.123.123 /auth=publickey /user=testuser /keyfile=pathofkeyfile C:\teraterm\ttermpro.exe testuser@192.168.123.123 /auth=publickey /user=testuser /keyfile=pathofkeyfile /ask4passwd ダブルクリックするだけでログインできるので、操作が楽。 あまり変なところにパスワードを保存するべきではないので、社内だけで使う開発環境など、限られた状況で利用するのがよい。]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>なにげに、sshでサーバーにログインする手間って、大きいんだけど、簡単にならない？</p>
<p>サーバー選んで、場合によってはポートを指定して、パスワード入力したり、鍵ファイル指定したり……</p>
<h3>答え</h3>
<p>teratermでは、コマンドオプションにひととおり指定ができるので、起動するだけでサーバーにSSHで接続するショートカットを作ることができる。</p>
<p><a href="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/01/teraterm1.png"><img src="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/01/teraterm1.png" alt="" title="teraterm1" width="567" height="308" class="alignnone size-full wp-image-2947" /></a></p>
<p><a href="http://ttssh2.sourceforge.jp/manual/ja/commandline/ttssh.html">コマンドラインオプション</a>の説明にしたがって、<br />
以下のような形で、ホストもパスワードも特別に設定したポートも鍵ファイルも持たせておくことができる。</p>
<pre class="bash">C:\teraterm\ttermpro.exe 192.168.123.123:23456 /auth=password /user=testuser /passwd=testpass
C:\teraterm\ttermpro.exe testuser@192.168.123.123 /auth=publickey /user=testuser /keyfile=pathofkeyfile
C:\teraterm\ttermpro.exe testuser@192.168.123.123 /auth=publickey /user=testuser /keyfile=pathofkeyfile /ask4passwd
</pre>
<p>ダブルクリックするだけでログインできるので、操作が楽。</p>
<p>あまり変なところにパスワードを保存するべきではないので、社内だけで使う開発環境など、限られた状況で利用するのがよい。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2946/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>祝日のリストが欲しい</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2912</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2912#comments</comments>
		<pubDate>Sun, 29 Jan 2012 23:39:43 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[develop]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2912</guid>
		<description><![CDATA[問題 日本の祝日のリストが欲しい。 Googleカレンダーなんかでは表示してるよね。配ってないの？ 答え 配ってる。iCalendar形式で配ってる。 ↑Googleカレンダーで、日本の祝日を自分のカレンダーに追加して、詳細画面を見るとよい。 カレンダーデータの方は一般公開されており、ログインしていなくても取得できる。URLは下記のとおり。 https://www.google.com/calendar/ical/ja.japanese%23holiday%40group.v.calendar.google.com/public/basic.ics iCalendarって？ カレンダー、スケジュールを表現できるデータで、仕様はRFC5545で規定されている。（仕様が膨大で、全部読むのは大変。日本語での概要はこちら。） カレンダー系のアプリ、システムは、iCalendar形式のデータに対応していることが多い。iCalendar形式のデータは多数存在し、iCalendar形式のデータに対応しているソフトも多数存在する。 例） Windowsメールなどのメールソフト付属のカレンダー機能、Googleカレンダー、iPhoneのカレンダーアプリ など iCalendar形式を取り扱えるphpライブラリ では、私たちもその仕様に乗りましょう。phpのライブラリあります。 iCalendar PHP iCalendar iCalendarの取り扱いが難しかったら、GoogleはもっとシンプルなXML形式でもカレンダーデータを公開しているので、そちらもおすすめ。 日本の祝日（XML） 他にも、iCalendar形式ではなかったりすることもあるが、他国の祝日、野球、サッカーの試合の日程、満月・新月・半月等の情報など、探すとおもしろそうなものがたくさん出てくる。]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>日本の祝日のリストが欲しい。</p>
<p>Googleカレンダーなんかでは表示してるよね。配ってないの？</p>
<p><iframe src="https://www.google.com/calendar/embed?src=ja.japanese%23holiday%40group.v.calendar.google.com&#038;ctz=Asia/Tokyo" style="border: 0" width="480" height="300" frameborder="0" scrolling="no"></iframe></p>
<h3>答え</h3>
<p>配ってる。iCalendar形式で配ってる。</p>
<p><a href="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/01/iCalendar.png"><img src="http://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/01/iCalendar-640x436.png" alt="" title="iCalendar" width="640" height="436" class="alignnone size-large wp-image-2945" /></a></p>
<p>↑Googleカレンダーで、日本の祝日を自分のカレンダーに追加して、詳細画面を見るとよい。</p>
<p>カレンダーデータの方は一般公開されており、ログインしていなくても取得できる。URLは下記のとおり。</p>
<p><a href="https://www.google.com/calendar/ical/ja.japanese%23holiday%40group.v.calendar.google.com/public/basic.ics">https://www.google.com/calendar/ical/ja.japanese%23holiday%40group.v.calendar.google.com/public/basic.ics</a></p>
<h4>iCalendarって？</h4>
<p>カレンダー、スケジュールを表現できるデータで、仕様は<a href="http://tools.ietf.org/html/rfc5545">RFC5545</a>で規定されている。（仕様が膨大で、全部読むのは大変。<a href="http://www.asahi-net.or.jp/~CI5M-NMR/iCal/ref.html">日本語での概要はこちら</a>。）</p>
<p>カレンダー系のアプリ、システムは、iCalendar形式のデータに対応していることが多い。iCalendar形式のデータは多数存在し、iCalendar形式のデータに対応しているソフトも多数存在する。</p>
<p>例） Windowsメールなどのメールソフト付属のカレンダー機能、Googleカレンダー、iPhoneのカレンダーアプリ など</p>
<h4>iCalendar形式を取り扱えるphpライブラリ</h4>
<p>では、私たちもその仕様に乗りましょう。phpのライブラリあります。</p>
<ul>
<li><a href="http://www.kigkonsult.se/iCalcreator/">iCalendar</a></li>
<li><a href="http://phpicalendar.net/">PHP iCalendar</a></li>
</ul>
<p>iCalendarの取り扱いが難しかったら、GoogleはもっとシンプルなXML形式でもカレンダーデータを公開しているので、そちらもおすすめ。</p>
<ul>
<li><a href="https://www.google.com/calendar/feeds/ja.japanese%23holiday%40group.v.calendar.google.com/public/basic">日本の祝日（XML）</a></li>
</ul>
<p>他にも、iCalendar形式ではなかったりすることもあるが、他国の祝日、野球、サッカーの試合の日程、満月・新月・半月等の情報など、探すとおもしろそうなものがたくさん出てくる。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2912/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>【正規表現】ある文字が2回連続している文字列にマッチする正規表現</title>
		<link>http://www.softel.co.jp/blogs/tech/archives/2942</link>
		<comments>http://www.softel.co.jp/blogs/tech/archives/2942#comments</comments>
		<pubDate>Sun, 29 Jan 2012 07:26:38 +0000</pubDate>
		<dc:creator>yoshimura</dc:creator>
				<category><![CDATA[develop]]></category>

		<guid isPermaLink="false">http://www.softel.co.jp/blogs/tech/?p=2942</guid>
		<description><![CDATA[問題 ある文字が2回連続している文字列にマッチする正規表現は？ apple → ○ orange → × success → ○ test-test → × www.softel.co.jp → ○ Oops → × 答え 後方参照を使う。 「ある文字」をキャプチャして、「その文字がもう1回現れた」を表す。 ある文字は「.」、キャプチャするには括弧「()」で囲み、キャプチャした文字列は「バックスラッシュ+何個目のキャプチャかを示す数字」と書く。 (.)\1 デモ 文字を入力してボタンをクリックすると、alertで結果をお知らせします。 /(.)\1/.test() 応用 同じ要領で、ある文字が3文字続いた場合などを検出できる。 /(.)\1\1/.test() 「あるフレーズが続けて2回繰り返されているかどうか」もこのとおり。 /(.+)\1/.test()]]></description>
			<content:encoded><![CDATA[<h3>問題</h3>
<p>ある文字が2回連続している文字列にマッチする正規表現は？</p>
<pre class="bash">apple → ○
orange → ×
success → ○
test-test → ×
www.softel.co.jp → ○
Oops → ×
</pre>
<h3>答え</h3>
<p>後方参照を使う。</p>
<p>「ある文字」をキャプチャして、「その文字がもう1回現れた」を表す。</p>
<p>ある文字は「.」、キャプチャするには括弧「()」で囲み、キャプチャした文字列は「バックスラッシュ+何個目のキャプチャかを示す数字」と書く。</p>
<pre class="bash">(.)\1</pre>
<h4>デモ</h4>
<p>文字を入力してボタンをクリックすると、alertで結果をお知らせします。</p>
<div style="padding:1em; border:8px solid #ccc;">/(.)\1/.test(<input type="text" value="apple" />) <input type="button" onclick="alert(/(.)\1/.test(this.parentNode.getElementsByTagName('input')[0].value))" value="正規表現にマッチするかチェック！" /></div>
<h4>応用</h4>
<p>同じ要領で、ある文字が3文字続いた場合などを検出できる。</p>
<div style="padding:1em; border:8px solid #ccc;">/(.)\1\1/.test(<input type="text" value="www.softel.co.jp" />) <input type="button" onclick="alert(/(.)\1\1/.test(this.parentNode.getElementsByTagName('input')[0].value))" value="正規表現にマッチするかチェック！" /></div>
<p>「あるフレーズが続けて2回繰り返されているかどうか」もこのとおり。</p>
<div style="padding:1em; border:8px solid #ccc;">/(.+)\1/.test(<input type="text" size="30" value="えー寿限無寿限無ごこうのすりきれ" />) <input type="button" onclick="alert(/(.+)\1/.test(this.parentNode.getElementsByTagName('input')[0].value))" value="正規表現にマッチするかチェック！" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.softel.co.jp/blogs/tech/archives/2942/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

