The blog of jumex - A Dubiously Digital Diglot

2005-03-31

Regular expressions 正規表現

平成17年3月30日水曜の日記
天気: 晴 行事: 赤来中

今日もぜんぜん仕事がありませんでした。ほとんどの日、やっぱり、ホームページに作っていました。今日のことはザ・トレブ・レポートをきれいになりました。一番難しい仕事はテクストファイルからXHTMLページまで変わるPerlスクリプトを書きました。Perl正規表現はすごく読みにくいけれどとっても強く便利します。日本語も少し勉強しました。今晩、飯南町教育委員会送別会でありました。頓原地域ALTのアリシアさんも来ました。アリシアさんは僕より日本語が上手になりました。うらやましいです。
おまけ:このPerl正規表現は何をしますか?
$x=~s!^.*[^\(\w|.\)]+([\(\w|.\)]+)(?=[^\(\w|.\)]*$y).*$!$1!sx;

暗示:この表現の前、xは限界がタブに定められたファイル・リストです。yはxの中でファイル名。一つのことでこの表現が失敗します。そのことは何でしょうか?

Journal for 2005-3-30 Wed.
Weather: Sunny Plan: Akagi JHS

I didn't have any work to do today. As you might have guess, I spent most of the day working on my web site. The task for today was to make The Trev Reports look SOOO GOOD. (alright, chill) The toughest part was writing a Perl script to convert a text file into a XHTML page. The regular expressions in Perl are really hard to read, but are very powerful and useful. I also studied a little Japanese. Tonight was the Iinan Town Board of Education Going Away Party for staff that are changing positions. Alicia, the ALT in Tonbara, was also there. Alicia's Japanese has become better than mine. I am jealous.
Bonus: What does this Perl regular expression do?
$x=~s!^.*[^\(\w|.\)]+([\(\w|.\)]+)(?=[^\(\w|.\)]*$y).*$!$1!sx;

Hint: before this expression, x is a tab-delimited file listing. y is the name of a file in x. There is one situation where this expression fails. Do you know what it is?

Today's Kanji
(今日の漢字)
Meaning (意味): dark

Chinese Reading (音読み):
Reading Romaji
アンan
Japanese Reading (訓読み):
Reading Romaji
くらkurai
Vocabulary (単語):
Word Reading Romaji Translation
暗いくらいkuraidark
暗記あんきankimemorization
暗殺あんさつansatsuassassination
暗算あんざんanzanmental arithmetic
暗示あんじanjihint
暗号あんごうangoupassword
明暗めいあんmeianlight and darkness


-- 
Trevor Lalish-Menagh
jumex@trevreport.org
 www.trevreport.org 
 011-81-854-76-3021 

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

[Check them out at Flickr!]
[Fight Spam! Click Here!]