2013年2月10日日曜日

開発環境

『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリー・ジャパン、2009年、ISBN978-4-87311-425-5) の4章(JavaScriptのオブジェクト)練習問第4-2.を解いてみる。

その他参考書籍

4-2.

コード(BBEdit)

var s = "The fun of functions is that they are functional.";
s = s.replace(/\bfun\b/g, "power");
$('#pre0').text(s);



ちなみにPython3kの場合。

コード(BBEdit)

sample.py

#!/usr/bin/env python3.3
# -*- coding: utf-8 -*-

import re
s = "The fun of functions is that they are functional."
result = re.sub(r"\bfun\b", "power", s)
print(result)

入出力結果(Terminal)

$ ./sample.py
The power of functions is that they are functional.
$

0 コメント:

コメントを投稿