- Jun 08 Wed 2011 08:53
-
UCSC DB remote connection
- May 25 Wed 2011 01:03
-
miRBase update
http://www.mirbase.org/blog/2011/04/whats-in-a-name/
miRBase 17 已於2011/4/26 released
- May 12 Thu 2011 10:10
-
【股票】聖暉 - 五月操作心得
似乎大股東會賣出手中部份持股轉現金
- May 11 Wed 2011 22:19
-
【系統】NFS server and client setting
- Mar 23 Wed 2011 05:07
-
【轉貼】LibSVM - tools的用法
http://pwwang.com/technology/svm/libsvm-288中文文档tools/
=================================================
- Mar 23 Wed 2011 04:08
-
【Python】讀檔 readlines, readline - 開啟大檔的方法

方法一:執行時間較短,但耗費記憶體 (readlines)
f = open(filename,'r')
for line in f.readlines():
if condition:
do something
f.close()
方法二:省記憶體,執行時間較久 - 適合開大檔
- Feb 22 Tue 2011 00:40
-
【轉貼】FirePHP for CakePHP 阿凱隨手紀
FirePHP for CakePHP 安裝 - 阿凱隨手紀
FirePHP,是 FireBug 的一個擴充,可以讓 FireBug 處理 FirePHPCore librar 輸出的錯誤訊息……
- Jan 11 Tue 2011 20:03
-
【Python】Parse網頁最好用的語言 - Python - lxml
- Dec 15 Wed 2010 15:58
-
PHP正規表示法支援Unicode
在安裝PHPExcel時,出現一行錯誤訊息
PHP Warning: preg_match(): Compilation failed: support for \P, \p, and \X has not ........
原來是因為我的CentOS的正規沒有支援unicode (可以先下 pcretest -C,看看是否有出現 'No Unicode properties support')
解決方式如下,此為轉自網路某人的解法:
I talked about how to get the most out of running
regular expressions in PHP. The reason that I needed to dig in deep on
regular expression syntax with PHP is because I needed to write some
regular expressions that deal with Unicode characters.
After much reading, I believed that I knew everything that I needed. I
started writing some regex strings and testing the code.
Unfortunately, every time I ran a test with a string that contained
Unicode characters, the match failed. When I removed the Unicode
characters from the string and tested again, it would work. I was
baffled.
Finding the Problem
I had the regex testing characters (‘\X’, ‘\pL’, etc) inside of a
character class, such as ‘[\X-]‘, since I was creating a regex to test
for domains. I wrote a really simple rule by simply looking for ‘/^\X$/’
and testing the regex with a single Unicode character. Amazingly,
having the ‘\X’ outside of the square brackets changed everything as I
now received the following very concerning warning:
PHP Warning: preg_match(): Compilation failed: support for \P,
\p, and \X has not been compiled at offset 2 in
wp-content/plugins/dnsyogi/testunicode.php on line 4
Since PHP uses the PCRE engine to run regular expressions, I started
to dig into it. I found out that I could query PCRE directly. I ended
up with something very similar:
1 | $ pcregrep ‘/\X*/u’ character.txt |
pcregrep: Error in command-line regex at offset 2: support for \P, \p, and \X has not been compiled
It looked like the error was coming from PCRE itself. I searched
around for a while thinking that I could simply install a new package
using yum. I hoped to find something like pcre-utf8, pcre-unicode,
php-pcre-unicode, or something to make it simple and quick to add this
support since I much prefer using package management tools rather than
compiling and installing from source.
Unfortunately, no such package exists. This support is something that
must be an option that PCRE is compiled with, and my CentOS repository
only has packages that don’t include that support. After much digging
around, I found that this isn’t necessarily CentOS’s fault as this
package has carried over from the RHEL (Red Hat Enterprice Linux) side
of things.
A great way of checking to see if this is an issue on your system is by running the following:
1 | $ pcretest -C |
This is the output that I received. Notice the “UTF-8 support” and
the “No Unicode properties support” lines. This means that PRCE was
compiled with the “–enable-utf8″ configure option which allows PCRE to
recognize and work with UTF-8 encoded strings. However, it wasn’t
compiled with the “–enable-unicode-properties” configure option which
works in conjunction with the enable-utf8 option to add support for the
‘\p’, ‘\P’, and ‘\X’ character classes.
This seems to have been an oversight when the rpm file was first put together. Fortunately, there is a way to fix it.
Fixing the Problem
Since I’m sure that many of you are like me and would rather not
manually compile and install software outside of the package management
system, the solution is to update the rpm to have the option that it
needs and install it.
I had never done this before. Fortunately, I found a very helpful guide that details this process out very nicely: How to patch and rebuild an RPM package.
I have provided the new rpm file that I have built at the bottom of
this post. If you don’t care about all this jibber-jabber, you can skip
down there and grab the file. However, if you would like to learn how
to address this issue yourself or have a system that my file will not
support, please read on to see how I rebuilt the rpm with the new
option.
Rebuilding the rpm
my platform. I’m on CentOS 5.2 with version 6.6 of PCRE. I found the
matching source rpm file (pcre-6.6-2.el5_1.7.src.rpm) here.
1 | $ rpm -ivh pcre-6.6-2.el5_1.7.src.rpm |
This put the necessary files into my ~/src/rpm/SOURCES and ~/src/rpm/SPECS folders.
Wrote: ~/src/rpm/SRPMS/pcre-6.6-2.7.src.rpm
Wrote: ~/src/rpm/RPMS/x86_64/pcre-6.6-2.7.x86_64.rpm
Wrote: ~/src/rpm/RPMS/x86_64/pcre-devel-6.6-2.7.x86_64.rpm
Wrote: ~/src/rpm/RPMS/x86_64/pcre-debuginfo-6.6-2.7.x86_64.rpm
This tells me exactly where I can find my new source rpm and rpm files.
Updated rpm File for CentOS 5.2 64-bit <--這是我所用的方法
If you are running a 64-bit version of CentOS 5.2, the following file
should work for you. If you have a different architecture, Linux
distro, or encounter any errors when trying to install this file, then
you should follow the instructions above to build an rpm that is
suitable for your distribution.
pcre-6.6-2.7.x86_64.rpm – PCRE 6.6 for CentOS 5.2 64-bit
Thanks Robin for providing a 32-bit version: pcre-6.6-2.7.i386.rpm
Installing New rpm
Now that I have my new rpm file, I just need to install it. Since I
already have a pcre package installed, I need to tell the rpm command to
update rather than install. The following command does this for me:
1 | # rpm -Uvh ~/src/rpm/RPMS/x86_64/pcre-6.6-2.7.x86_64.rpm |
Notice that I need to be root to run this command.
Finally, to verify that everything worked, I ran the pcrecheck program again:
1 | <pre>$ pcretest -C |
Looks good.
- Dec 01 Wed 2010 01:42
-
【轉貼】常用的Python指令
- Nov 25 Thu 2010 12:52
-
【PHP】PHPExcel and PHPPowerPoint - 轉貼
- Nov 17 Wed 2010 10:36
-
【轉錄】CentOS安裝
Linux除了可以以光碟DVD-iso安裝外,也可以使用網路安裝
尤其是那種老舊電腦,只有CD-Rom光碟機,沒有DVD光碟機
就可以使用網路來安裝
首先先到義守大學的檔案伺服器去download網路安裝開機ISO檔燒成光碟
http://ftp.isu.edu.tw/pub/Linux/CentOS/5.5/isos/i386/CentOS-5.5-i386-netinstall.iso
接著將開機光碟放入光碟機中,使用光碟開機
依照提示先設定好IP後,再指定安裝來源
安裝來源選擇HTTP或FTP,接著輸入伺服器名稱和位址
如http來源設定為
ftp.isu.edu.tw/pub/Linux/CentOS/5.5/isos/i386/
接著依照提示下一步設定要安裝的套件後即可完成安裝,網路愈快當然安裝的愈快囉~~
另外,若要是電腦老舊到連CD-Rom也沒有怎麼辦!
還可以使用USB隨身碟來安裝Linux,不過電腦得先support USB開機
先利用UNetbootin這支程式來建立USB開機檔
http://unetbootin.sourceforge.net/ (只能使用網路安裝,或預先把映像檔放在硬碟中)
建立好後,使用USB隨身碟開機後,再如同上面的步驟使用網路安裝即可
