前の日 / 次の日 / 最新

WinChalow

2005 : Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2004 : Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

2004-12-17 Fri

ニシキエビを県内で捕獲 /山口


http://headlines.yahoo.co.jp/hl?a=20041216-00000194-mailo-l35

熱帯性の大型エビが瀬戸内海で捕獲された。最近、この手の話が多い。

もっとも、夏になれば千葉の海でも熱帯魚がみられるので、驚くほどのことではない。
http://chiba.yc1.co.jp/seapool/sea_uchibo.htm
(2004-12-17 16:09:40)

正規表現お助けツール


.Net 対応のフリーソフトがある。
Regex Master
http://www.miningtools.net/master/default.aspx
Regex を与えると、テスト用パターンを自動生成する。私がほしいモノとは逆であった。日本語が化ける。

正規表現の例示集
Regular Expressions .NET by Example
http://www.miningtools.net/forums/forum.asp?FORUM_ID=4

いつのまにか正規表現が.Netのウリになっている。

遺伝的アルゴリズムがどうとかいっている論文のようなものもある。
random generation of regular expressions
http://lists.canonical.org/pipermail/kragen-hacks/2004-January/000375.html
(2004-12-17 14:19:52)

正規表現の自動生成 その2


文字列はすべて '.*' に変換するのをデフォルトとして、ユーザーが指定したセパレータのみを特別扱いするという戦略を採用してみるテスト。

ChangeLog フォーマットのアイテム・ヘッダーの正規表現を作らせてみた。
#!/usr/bin/perl -w
# $Id: genreg3.pl,v 1.1 2004/12/17 04:33:44 zuihu Exp $
# This script should be saved in UTF-8.

require 5.008;
use strict;
use utf8;
use Encode qw(encode);

# ここからユーザー指定項目 #
# 例示文字列
my $ex = "\t* CGI 開発ツール KCatch.pm [perl]:";
# 制約
my @separators = qw( \[ \] ); # 文字列として一般化しない記号
my $head = '\t\* '; # 頭部指定
my $tail = '\:'; # 尾部指定
# ここまでユーザー指定項目 #

print encode('Shift_JIS', $ex), "\n";

# 下準備
my $text = $ex;
$text =~ s/^($head)// if ($head && $head ne "");
$text =~ s/($tail)$// if ($tail && $tail ne "");

# 本作業
$text =~ s/([^\[\]]+)/(\.\*)/og;
for my $s (@separators)
{
$text =~ s/$s/\\$s/g;
$text =~ s/\\\\/\\/g;
}
my $pat = '^(' . $head . ')' if ($head && $head ne "");
$pat .= $text;
$pat .= $tail . '$' if ($tail && $tail ne "");

print encode('Shift_JIS', $pat), "\n";

# できあがった正規表現をテスト
$ex = "Regex NG." unless $ex =~ s/$pat/Regex OK./;
print encode('Shift_JIS', $ex), "\n";


スクリプトの出力
\t* CGI 開発ツール KCatch.pm [perl]:
^(\t\* )(.*)\[(.*)\]\:$
Regex OK.

だいぶ手間がはぶけるように思うのは私だけだろうか。

(2004-12-17 13:51:12)

2004-12 / 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31