開発環境
- OS X Lion - Apple(OS)
- Safari、Firefox + Firebug (Webプラウザ、プラグイン)
- BBEdit - Bare Bones Software, Inc.(Text Editor)
- プログラミング言語:JavaScript
- JavaScript Library: jQuery
『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリー・ジャパン、2009年、ISBN978-4-87311-425-5) の4章(JavaScriptオブジェクト)練習問第4-2.を解いてみる。
その他参考書籍
2.
コード(BBEdit)
var str = "The fun of functions is that they are functional.", replaced = str.replace(/\bfun\b/g, "power"), result = "置換前: " + str + "\n" + "置換後: " + replaced; $('#pre0').text(result);
ちなみにPython3.3の場合。
コード(BBEdit)
sample.py
#!/usr/bin/env python3.3 # -*- coding: utf-8 -*- import re s = "The fun of functions is that they are functional." replaced = re.sub(r"\bfun\b", "power", s) print("置換前: {0}".format(s)) print("置換後: {0}".format(replaced))
入出力結果(Terminal)
$ ./sample.py 置換前: The fun of functions is that they are functional. 置換後: The power of functions is that they are functional. $
0 コメント:
コメントを投稿