C语言的一个正则表达式pcre

来源:互联网 发布:linux 终端输入中文 编辑:程序博客网 时间:2024/05/24 04:13

1. 简介

在C/C++中,一个比较好的正则表达式是pcre,被很多工具(包括一些商用工具)使用。

2. 源码下载&安装

2.1 下载

可以从官网http://www.pcre.org/下载,为方便学习,已放在这里http://download.csdn.net/detail/u013344915/7793027。

2.2 Windows上的安装过程

参考:Windows上面编译pcre的步骤

2.3 Linux上面的安装过程

在Linux下面,就是执行典型的3个命令即可:

  • ./configure
  • make
  • sudo make install  //需要root权限,所以前面加了sudo

最后会安装在/usr/local/include,lib等目录中。——本文最后附上整个安装的日志。

当然,不一定要把pcre安装到/usr/local目录,可以自己编译一个lib。在pcre文档中有这方面的介绍,后面有空再补充这一块。

3. 示例

在pcre源码中,提供了一个示例代码,即pcredemo.c。但这个仍然有点复杂,所以参考这个文件,下面给出一个更简单的例子。


3.1 只匹配一次

从日期中提取出年月日:比如从"2014-08-20"中提取出年月日三个信息,即2014, 08, 20。我们用pcre来实现这个功能。


代码如下:

/* gcc -Wall test-pcre.c -lpcre -o testpcre or gcc -Wall test-pcre.c -I/usr/local/include -L/usr/local/lib -lpcre -o testpcre */#include <stdio.h>#include <string.h>#include <pcre.h>#define OVECCOUNT 30    /* should be a multiple of 3 */int main(int argc, char **argv) {pcre *re;const char *error;char *pattern;char *date;int erroffset;int ovector[OVECCOUNT];int subject_length;int rc, i;pattern = "(\\d+)-(\\d+)-(\\d+)";date = "2014-08-20";subject_length = (int) strlen(date);/************************************************************************* * Now we are going to compile the regular expression pattern, and handle * * and errors that are detected.                                          * *************************************************************************/re = pcre_compile(pattern, /* the pattern */0, /* default options */&error, /* for error message */&erroffset, /* for error offset */NULL); /* use default character tables *//* Compilation failed: print the error message and exit */if (re == NULL) {printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);return 1;}/************************************************************************* * If the compilation succeeded, we call PCRE again, in order to do a     * * pattern match against the subject string. This does just ONE match. If * * further matching is needed, it will be done below.                     * *************************************************************************/rc = pcre_exec(re, /* the compiled pattern */NULL, /* no extra data - we didn't study the pattern */date, /* the subject string */subject_length, /* the length of the subject */0, /* start at offset 0 in the subject */0, /* default options */ovector, /* output vector for substring information */OVECCOUNT); /* number of elements in the output vector *//* Matching failed: handle error cases */if (rc < 0) {switch (rc) {case PCRE_ERROR_NOMATCH:printf("No match\n");break;/* Handle other special cases if you like */default:printf("Matching error %d\n", rc);break;}pcre_free(re); /* Release memory used for the compiled pattern */return 1;}/* Match succeded */printf("\nMatch succeeded at offset %d\n", ovector[0]);/************************************************************************* * We have found the first match within the subject string. If the output * * vector wasn't big enough, say so. Then output any substrings that were * * captured.                                                              * *************************************************************************//* The output vector wasn't big enough */if (rc == 0) {rc = OVECCOUNT / 3;printf("ovector only has room for %d captured substrings\n", rc - 1);}/* Show substrings stored in the output vector by number. Obviously, in a real application you might want to do things other than print them. */for (i = 0; i < rc; i++) {char *substring_start = date + ovector[2 * i];int substring_length = ovector[2 * i + 1] - ovector[2 * i];printf("%2d: %.*s\n", i, substring_length, substring_start);}printf("\n");pcre_free(re); /* Release memory used for the compiled pattern */return 0;}

运行结果:

flying-bird@flyingbird:~/workspace/StudentExample/src$ gcc -Wall test-pcre.c -lpcre -o testpcreflying-bird@flyingbird:~/workspace/StudentExample/src$ ./testpcre ./testpcre: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directoryflying-bird@flyingbird:~/workspace/StudentExample/src$ ll /usr/local/lib/libpcre.so.1lrwxrwxrwx 1 root root 16  8月 20 20:33 /usr/local/lib/libpcre.so.1 -> libpcre.so.1.2.3*flying-bird@flyingbird:~/workspace/StudentExample/src$ sudo ldconfig[sudo] password for flying-bird: flying-bird@flyingbird:~/workspace/StudentExample/src$ ./testpcre Match succeeded at offset 0 0: 2014-08-20 1: 2014 2: 08 3: 20flying-bird@flyingbird:~/workspace/StudentExample/src$ 


3.2 多次匹配

上面的例子是一次匹配,且一次匹配了多个子串。这里换一种匹配方式,即多次匹配。这要用到pcre_exec的start_offset参数,指定从指定的字符串的哪个位置开始匹配。


为此,现在把匹配串做一点修改,不再匹配年月日,而是匹配连续的数字串。因此,希望匹配出年,然后匹配出月,以及日。通过上面的例子,一次pcre_exec()只能匹配出一个串,所以要修改代码,有如下几点:

  • 增加一个 int subject_offset,说明从字符串的哪个位置开始匹配;
  • 加了一个for循环,持续地匹配,直到找不到匹配的串为止;
  • for循环内部,每次匹配到之后,就调整subject_offset。

// testpcre.cpp : Defines the entry point for the console application.///* gcc -Wall test-pcre.c -lpcre -o testpcre or gcc -Wall test-pcre.c -I/usr/local/include -L/usr/local/lib -lpcre -o testpcre */#include <stdio.h>#include <string.h>#include "pcre.h"//#define PCRE_STATIC#define OVECCOUNT 30    /* should be a multiple of 3 */int main(int argc, char **argv) {pcre *re;const char *error;char *pattern;char *date;int erroffset;int ovector[OVECCOUNT];int subject_length;int rc, i;int subject_offset = 0;pattern = "(\\d+)";date = "2014-08-20";subject_length = (int) strlen(date);/************************************************************************* * Now we are going to compile the regular expression pattern, and handle * * and errors that are detected.                                          * *************************************************************************/re = pcre_compile(pattern, /* the pattern */0, /* default options */&error, /* for error message */&erroffset, /* for error offset */NULL); /* use default character tables *//* Compilation failed: print the error message and exit */if (re == NULL) {printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);return 1;}/************************************************************************* * If the compilation succeeded, we call PCRE again, in order to do a     * * pattern match against the subject string. This does just ONE match. If * * further matching is needed, it will be done below.                     * *************************************************************************/for (;;) {rc = pcre_exec(re, /* the compiled pattern */NULL, /* no extra data - we didn't study the pattern */date, /* the subject string */subject_length, /* the length of the subject */subject_offset, /* start at offset 0 in the subject */0, /* default options */ovector, /* output vector for substring information */OVECCOUNT); /* number of elements in the output vector *//* Matching failed: handle error cases */if (rc < 0) {switch (rc) {case PCRE_ERROR_NOMATCH:printf("No match\n");break;/* Handle other special cases if you like */default:printf("Matching error %d\n", rc);break;}pcre_free(re); /* Release memory used for the compiled pattern */return 1;}/* Match succeded */printf("\nMatch succeeded at offset %d\n", ovector[0]);/************************************************************************* * We have found the first match within the subject string. If the output * * vector wasn't big enough, say so. Then output any substrings that were * * captured.                                                              * *************************************************************************//* The output vector wasn't big enough */if (rc == 0) {rc = OVECCOUNT / 3;printf("ovector only has room for %d captured substrings\n", rc - 1);}/* Show substrings stored in the output vector by number. Obviously, in a real application you might want to do things other than print them. */for (i = 0; i < rc; i++) {char *substring_start = date + ovector[2 * i];int substring_length = ovector[2 * i + 1] - ovector[2 * i];printf("%2d: %.*s\n", i, substring_length, substring_start);}printf("\n");subject_offset = ovector[1];}pcre_free(re); /* Release memory used for the compiled pattern */return 0;}



4. Ubuntu安装日志

flying-bird@flyingbird:~/software/pcre-8.35$ ll ./configure-rwxr-xr-x 1 flying-bird flying-bird 677106  4月  4 14:39 ./configure*flying-bird@flyingbird:~/software/pcre-8.35$ ./configurechecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether make supports nested variables... (cached) yeschecking for style of include used by make... GNUchecking for gcc... gccchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables... checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking whether gcc understands -c and -o together... yeschecking dependency style of gcc... gcc3checking for ar... archecking the archiver (ar) interface... archecking for gcc... (cached) gccchecking whether we are using the GNU C compiler... (cached) yeschecking whether gcc accepts -g... (cached) yeschecking for gcc option to accept ISO C89... (cached) none neededchecking whether gcc understands -c and -o together... (cached) yeschecking dependency style of gcc... (cached) gcc3checking for g++... g++checking whether we are using the GNU C++ compiler... yeschecking whether g++ accepts -g... yeschecking dependency style of g++... gcc3checking how to run the C preprocessor... gcc -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking for int64_t... yeschecking build system type... i686-pc-linux-gnuchecking host system type... i686-pc-linux-gnuchecking how to print strings... printfchecking for a sed that does not truncate output... /bin/sedchecking for fgrep... /bin/grep -Fchecking for ld used by gcc... /usr/bin/ldchecking if the linker (/usr/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -Bchecking the name lister (/usr/bin/nm -B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking whether the shell understands some XSI constructs... yeschecking whether the shell understands "+="... yeschecking how to convert i686-pc-linux-gnu file names to i686-pc-linux-gnu format... func_convert_file_noopchecking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noopchecking for /usr/bin/ld option to reload object files... -rchecking for objdump... objdumpchecking how to recognize dependent libraries... pass_allchecking for dlltool... dlltoolchecking how to associate runtime and link libraries... printf %s\nchecking for archiver @FILE support... @checking for strip... stripchecking for ranlib... ranlibchecking command to parse /usr/bin/nm -B output from gcc object... okchecking for sysroot... nochecking for mt... mtchecking if mt is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if gcc supports -fno-rtti -fno-exceptions... nochecking for gcc option to produce PIC... -fPIC -DPICchecking if gcc PIC flag -fPIC -DPIC works... yeschecking if gcc static flag -static works... yeschecking if gcc supports -c -o file.o... yeschecking if gcc supports -c -o file.o... (cached) yeschecking whether the gcc linker (/usr/bin/ld) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... GNU/Linux ld.sochecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... yeschecking how to run the C++ preprocessor... g++ -Echecking for ld used by g++... /usr/bin/ldchecking if the linker (/usr/bin/ld) is GNU ld... yeschecking whether the g++ linker (/usr/bin/ld) supports shared libraries... yeschecking for g++ option to produce PIC... -fPIC -DPICchecking if g++ PIC flag -fPIC -DPIC works... yeschecking if g++ static flag -static works... yeschecking if g++ supports -c -o file.o... yeschecking if g++ supports -c -o file.o... (cached) yeschecking whether the g++ linker (/usr/bin/ld) supports shared libraries... yeschecking dynamic linker characteristics... (cached) GNU/Linux ld.sochecking how to hardcode library paths into programs... immediatechecking whether ln -s works... yeschecking whether the -Werror option is usable... yeschecking for simple visibility declarations... yeschecking for ANSI C header files... (cached) yeschecking limits.h usability... yeschecking limits.h presence... yeschecking for limits.h... yeschecking for sys/types.h... (cached) yeschecking for sys/stat.h... (cached) yeschecking dirent.h usability... yeschecking dirent.h presence... yeschecking for dirent.h... yeschecking windows.h usability... nochecking windows.h presence... nochecking for windows.h... nochecking for alias support in the linker... nochecking for alias support in the linker... nochecking string usability... yeschecking string presence... yeschecking for string... yeschecking bits/type_traits.h usability... nochecking bits/type_traits.h presence... nochecking for bits/type_traits.h... nochecking type_traits.h usability... nochecking type_traits.h presence... nochecking for type_traits.h... nochecking for strtoq... yeschecking for long long... yeschecking for unsigned long long... yeschecking for an ANSI C-conforming const... yeschecking for size_t... yeschecking for bcopy... yeschecking for memmove... yeschecking for strerror... yeschecking zlib.h usability... nochecking zlib.h presence... nochecking for zlib.h... nochecking for gzopen in -lz... nochecking bzlib.h usability... nochecking bzlib.h presence... nochecking for bzlib.h... nochecking for libbz2... nochecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating libpcre.pcconfig.status: creating libpcre16.pcconfig.status: creating libpcre32.pcconfig.status: creating libpcreposix.pcconfig.status: creating libpcrecpp.pcconfig.status: creating pcre-configconfig.status: creating pcre.hconfig.status: creating pcre_stringpiece.hconfig.status: creating pcrecpparg.hconfig.status: creating config.hconfig.status: executing depfiles commandsconfig.status: executing libtool commandsconfig.status: executing script-chmod commandsconfig.status: executing delete-old-chartables commandspcre-8.35 configuration summary:    Install prefix .................. : /usr/local    C preprocessor .................. : gcc -E    C compiler ...................... : gcc    C++ preprocessor ................ : g++ -E    C++ compiler .................... : g++    Linker .......................... : /usr/bin/ld    C preprocessor flags ............ :     C compiler flags ................ : -g -O2 -fvisibility=hidden    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden    Linker flags .................... :     Extra libraries ................. :     Build 8 bit pcre library ........ : yes    Build 16 bit pcre library ....... : no    Build 32 bit pcre library ....... : no    Build C++ library ............... : yes    Enable JIT compiling support .... : no    Enable UTF-8/16/32 support ...... : no    Unicode properties .............. : no    Newline char/sequence ........... : lf    \R matches only ANYCRLF ......... : no    EBCDIC coding ................... : no    EBCDIC code for NL .............. : n/a    Rebuild char tables ............. : no    Use stack recursion ............. : yes    POSIX mem threshold ............. : 10    Internal link size .............. : 2    Nested parentheses limit ........ : 250    Match limit ..................... : 10000000    Match limit recursion ........... : MATCH_LIMIT    Build shared libs ............... : yes    Build static libs ............... : yes    Use JIT in pcregrep ............. : no    Buffer size for pcregrep ........ : 20480    Link pcregrep with libz ......... : no    Link pcregrep with libbz2 ....... : no    Link pcretest with libedit ...... : no    Link pcretest with libreadline .. : no    Valgrind support ................ : no    Code coverage ................... : noflying-bird@flyingbird:~/software/pcre-8.35$ makerm -f pcre_chartables.cln -s ./pcre_chartables.c.dist pcre_chartables.cmake  all-ammake[1]: Entering directory `/home/flying-bird/software/pcre-8.35'  CC       libpcre_la-pcre_byte_order.lo  CC       libpcre_la-pcre_compile.lo  CC       libpcre_la-pcre_config.lo  CC       libpcre_la-pcre_dfa_exec.lo  CC       libpcre_la-pcre_exec.lo  CC       libpcre_la-pcre_fullinfo.lo  CC       libpcre_la-pcre_get.lo  CC       libpcre_la-pcre_globals.lo  CC       libpcre_la-pcre_jit_compile.lo  CC       libpcre_la-pcre_maketables.lo  CC       libpcre_la-pcre_newline.lo  CC       libpcre_la-pcre_ord2utf8.lo  CC       libpcre_la-pcre_refcount.lo  CC       libpcre_la-pcre_string_utils.lo  CC       libpcre_la-pcre_study.lo  CC       libpcre_la-pcre_tables.lo  CC       libpcre_la-pcre_ucd.lo  CC       libpcre_la-pcre_valid_utf8.lo  CC       libpcre_la-pcre_version.lo  CC       libpcre_la-pcre_xclass.lo  CC       libpcre_la-pcre_chartables.lo  CCLD     libpcre.la  CC       libpcreposix_la-pcreposix.lo  CCLD     libpcreposix.la  CXX      libpcrecpp_la-pcrecpp.lo  CXX      libpcrecpp_la-pcre_scanner.lo  CXX      libpcrecpp_la-pcre_stringpiece.lo  CXXLD    libpcrecpp.la  CC       pcretest-pcretest.o  CC       pcretest-pcre_printint.o  CCLD     pcretest  CC       pcregrep-pcregrep.o  CCLD     pcregrep  CXX      pcrecpp_unittest-pcrecpp_unittest.o  CXXLD    pcrecpp_unittest  CXX      pcre_scanner_unittest-pcre_scanner_unittest.o  CXXLD    pcre_scanner_unittest  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o  CXXLD    pcre_stringpiece_unittestmake[1]: Leaving directory `/home/flying-bird/software/pcre-8.35'flying-bird@flyingbird:~/software/pcre-8.35$ sudo make install[sudo] password for flying-bird: make  install-ammake[1]: Entering directory `/home/flying-bird/software/pcre-8.35'make[2]: Entering directory `/home/flying-bird/software/pcre-8.35' /bin/mkdir -p '/usr/local/lib' /bin/bash ./libtool   --mode=install /usr/bin/install -c   libpcre.la libpcreposix.la libpcrecpp.la '/usr/local/lib'libtool: install: /usr/bin/install -c .libs/libpcre.so.1.2.3 /usr/local/lib/libpcre.so.1.2.3libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.3 libpcre.so.1 || { rm -f libpcre.so.1 && ln -s libpcre.so.1.2.3 libpcre.so.1; }; })libtool: install: (cd /usr/local/lib && { ln -s -f libpcre.so.1.2.3 libpcre.so || { rm -f libpcre.so && ln -s libpcre.so.1.2.3 libpcre.so; }; })libtool: install: /usr/bin/install -c .libs/libpcre.lai /usr/local/lib/libpcre.lalibtool: install: warning: relinking `libpcreposix.la'libtool: install: (cd /home/flying-bird/software/pcre-8.35; /bin/bash /home/flying-bird/software/pcre-8.35/libtool  --silent --tag CC --mode=relink gcc -fvisibility=hidden -g -O2 -version-info 0:2:0 -o libpcreposix.la -rpath /usr/local/lib libpcreposix_la-pcreposix.lo libpcre.la )libtool: install: /usr/bin/install -c .libs/libpcreposix.so.0.0.2T /usr/local/lib/libpcreposix.so.0.0.2libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.2 libpcreposix.so.0 || { rm -f libpcreposix.so.0 && ln -s libpcreposix.so.0.0.2 libpcreposix.so.0; }; })libtool: install: (cd /usr/local/lib && { ln -s -f libpcreposix.so.0.0.2 libpcreposix.so || { rm -f libpcreposix.so && ln -s libpcreposix.so.0.0.2 libpcreposix.so; }; })libtool: install: /usr/bin/install -c .libs/libpcreposix.lai /usr/local/lib/libpcreposix.lalibtool: install: warning: relinking `libpcrecpp.la'libtool: install: (cd /home/flying-bird/software/pcre-8.35; /bin/bash /home/flying-bird/software/pcre-8.35/libtool  --silent --tag CXX --mode=relink g++ -fvisibility=hidden -fvisibility-inlines-hidden -O2 -version-info 0:0:0 -o libpcrecpp.la -rpath /usr/local/lib libpcrecpp_la-pcrecpp.lo libpcrecpp_la-pcre_scanner.lo libpcrecpp_la-pcre_stringpiece.lo libpcre.la )libtool: install: /usr/bin/install -c .libs/libpcrecpp.so.0.0.0T /usr/local/lib/libpcrecpp.so.0.0.0libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.0 libpcrecpp.so.0 || { rm -f libpcrecpp.so.0 && ln -s libpcrecpp.so.0.0.0 libpcrecpp.so.0; }; })libtool: install: (cd /usr/local/lib && { ln -s -f libpcrecpp.so.0.0.0 libpcrecpp.so || { rm -f libpcrecpp.so && ln -s libpcrecpp.so.0.0.0 libpcrecpp.so; }; })libtool: install: /usr/bin/install -c .libs/libpcrecpp.lai /usr/local/lib/libpcrecpp.lalibtool: install: /usr/bin/install -c .libs/libpcre.a /usr/local/lib/libpcre.alibtool: install: chmod 644 /usr/local/lib/libpcre.alibtool: install: ranlib /usr/local/lib/libpcre.alibtool: install: /usr/bin/install -c .libs/libpcreposix.a /usr/local/lib/libpcreposix.alibtool: install: chmod 644 /usr/local/lib/libpcreposix.alibtool: install: ranlib /usr/local/lib/libpcreposix.alibtool: install: /usr/bin/install -c .libs/libpcrecpp.a /usr/local/lib/libpcrecpp.alibtool: install: chmod 644 /usr/local/lib/libpcrecpp.alibtool: install: ranlib /usr/local/lib/libpcrecpp.alibtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib----------------------------------------------------------------------Libraries have been installed in:   /usr/local/libIf you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify the full pathname of the library, or use the `-LLIBDIR'flag during linking and do at least one of the following:   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable     during execution   - add LIBDIR to the `LD_RUN_PATH' environment variable     during linking   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag   - have your system administrator add LIBDIR to `/etc/ld.so.conf'See any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.---------------------------------------------------------------------- /bin/mkdir -p '/usr/local/bin'  /bin/bash ./libtool   --mode=install /usr/bin/install -c pcretest pcregrep '/usr/local/bin'libtool: install: /usr/bin/install -c .libs/pcretest /usr/local/bin/pcretestlibtool: install: /usr/bin/install -c .libs/pcregrep /usr/local/bin/pcregrep /bin/mkdir -p '/usr/local/bin' /usr/bin/install -c pcre-config '/usr/local/bin' /bin/mkdir -p '/usr/local/share/doc/pcre' /usr/bin/install -c -m 644 doc/pcre.txt doc/pcre-config.txt doc/pcregrep.txt doc/pcretest.txt AUTHORS COPYING ChangeLog LICENCE NEWS README '/usr/local/share/doc/pcre' /bin/mkdir -p '/usr/local/share/doc/pcre/html' /usr/bin/install -c -m 644 doc/html/NON-AUTOTOOLS-BUILD.txt doc/html/README.txt doc/html/index.html doc/html/pcre-config.html doc/html/pcre.html doc/html/pcre16.html doc/html/pcre32.html doc/html/pcre_assign_jit_stack.html doc/html/pcre_compile.html doc/html/pcre_compile2.html doc/html/pcre_config.html doc/html/pcre_copy_named_substring.html doc/html/pcre_copy_substring.html doc/html/pcre_dfa_exec.html doc/html/pcre_exec.html doc/html/pcre_free_study.html doc/html/pcre_free_substring.html doc/html/pcre_free_substring_list.html doc/html/pcre_fullinfo.html doc/html/pcre_get_named_substring.html doc/html/pcre_get_stringnumber.html doc/html/pcre_get_stringtable_entries.html doc/html/pcre_get_substring.html doc/html/pcre_get_substring_list.html doc/html/pcre_jit_exec.html doc/html/pcre_jit_stack_alloc.html doc/html/pcre_jit_stack_free.html doc/html/pcre_maketables.html doc/html/pcre_pattern_to_host_byte_order.html doc/html/pcre_refcount.html doc/html/pcre_study.html doc/html/pcre_utf16_to_host_byte_order.html doc/html/pcre_utf32_to_host_byte_order.html doc/html/pcre_version.html doc/html/pcreapi.html doc/html/pcrebuild.html doc/html/pcrecallout.html doc/html/pcrecompat.html doc/html/pcredemo.html doc/html/pcregrep.html '/usr/local/share/doc/pcre/html' /usr/bin/install -c -m 644 doc/html/pcrejit.html doc/html/pcrelimits.html doc/html/pcrematching.html doc/html/pcrepartial.html doc/html/pcrepattern.html doc/html/pcreperform.html doc/html/pcreposix.html doc/html/pcreprecompile.html doc/html/pcresample.html doc/html/pcrestack.html doc/html/pcresyntax.html doc/html/pcretest.html doc/html/pcreunicode.html '/usr/local/share/doc/pcre/html' /bin/mkdir -p '/usr/local/share/doc/pcre/html' /usr/bin/install -c -m 644 doc/html/pcrecpp.html '/usr/local/share/doc/pcre/html' /bin/mkdir -p '/usr/local/include' /usr/bin/install -c -m 644 pcreposix.h pcrecpp.h pcre_scanner.h '/usr/local/include' /bin/mkdir -p '/usr/local/share/man/man1' /usr/bin/install -c -m 644 doc/pcre-config.1 doc/pcregrep.1 doc/pcretest.1 '/usr/local/share/man/man1' /bin/mkdir -p '/usr/local/share/man/man3' /usr/bin/install -c -m 644 doc/pcre.3 doc/pcre16.3 doc/pcre32.3 doc/pcre_assign_jit_stack.3 doc/pcre_compile.3 doc/pcre_compile2.3 doc/pcre_config.3 doc/pcre_copy_named_substring.3 doc/pcre_copy_substring.3 doc/pcre_dfa_exec.3 doc/pcre_exec.3 doc/pcre_free_study.3 doc/pcre_free_substring.3 doc/pcre_free_substring_list.3 doc/pcre_fullinfo.3 doc/pcre_get_named_substring.3 doc/pcre_get_stringnumber.3 doc/pcre_get_stringtable_entries.3 doc/pcre_get_substring.3 doc/pcre_get_substring_list.3 doc/pcre_jit_exec.3 doc/pcre_jit_stack_alloc.3 doc/pcre_jit_stack_free.3 doc/pcre_maketables.3 doc/pcre_pattern_to_host_byte_order.3 doc/pcre_refcount.3 doc/pcre_study.3 doc/pcre_utf16_to_host_byte_order.3 doc/pcre_utf32_to_host_byte_order.3 doc/pcre_version.3 doc/pcreapi.3 doc/pcrebuild.3 doc/pcrecallout.3 doc/pcrecompat.3 doc/pcredemo.3 doc/pcrejit.3 doc/pcrelimits.3 doc/pcrematching.3 doc/pcrepartial.3 doc/pcrepattern.3 '/usr/local/share/man/man3' /usr/bin/install -c -m 644 doc/pcreperform.3 doc/pcreposix.3 doc/pcreprecompile.3 doc/pcresample.3 doc/pcrestack.3 doc/pcresyntax.3 doc/pcreunicode.3 doc/pcrecpp.3 '/usr/local/share/man/man3' /bin/mkdir -p '/usr/local/include' /usr/bin/install -c -m 644 pcre.h pcrecpparg.h pcre_stringpiece.h '/usr/local/include' /bin/mkdir -p '/usr/local/lib/pkgconfig' /usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcrecpp.pc '/usr/local/lib/pkgconfig'make  install-data-hookmake[3]: Entering directory `/home/flying-bird/software/pcre-8.35'ln -sf pcre_assign_jit_stack.3 /usr/local/share/man/man3/pcre16_assign_jit_stack.3ln -sf pcre_compile.3 /usr/local/share/man/man3/pcre16_compile.3ln -sf pcre_compile2.3 /usr/local/share/man/man3/pcre16_compile2.3ln -sf pcre_config.3 /usr/local/share/man/man3/pcre16_config.3ln -sf pcre_copy_named_substring.3 /usr/local/share/man/man3/pcre16_copy_named_substring.3ln -sf pcre_copy_substring.3 /usr/local/share/man/man3/pcre16_copy_substring.3ln -sf pcre_dfa_exec.3 /usr/local/share/man/man3/pcre16_dfa_exec.3ln -sf pcre_exec.3 /usr/local/share/man/man3/pcre16_exec.3ln -sf pcre_free_study.3 /usr/local/share/man/man3/pcre16_free_study.3ln -sf pcre_free_substring.3 /usr/local/share/man/man3/pcre16_free_substring.3ln -sf pcre_free_substring_list.3 /usr/local/share/man/man3/pcre16_free_substring_list.3ln -sf pcre_fullinfo.3 /usr/local/share/man/man3/pcre16_fullinfo.3ln -sf pcre_get_named_substring.3 /usr/local/share/man/man3/pcre16_get_named_substring.3ln -sf pcre_get_stringnumber.3 /usr/local/share/man/man3/pcre16_get_stringnumber.3ln -sf pcre_get_stringtable_entries.3 /usr/local/share/man/man3/pcre16_get_stringtable_entries.3ln -sf pcre_get_substring.3 /usr/local/share/man/man3/pcre16_get_substring.3ln -sf pcre_get_substring_list.3 /usr/local/share/man/man3/pcre16_get_substring_list.3ln -sf pcre_jit_exec.3 /usr/local/share/man/man3/pcre16_jit_exec.3ln -sf pcre_jit_stack_alloc.3 /usr/local/share/man/man3/pcre16_jit_stack_alloc.3ln -sf pcre_jit_stack_free.3 /usr/local/share/man/man3/pcre16_jit_stack_free.3ln -sf pcre_maketables.3 /usr/local/share/man/man3/pcre16_maketables.3ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre16_pattern_to_host_byte_order.3ln -sf pcre_refcount.3 /usr/local/share/man/man3/pcre16_refcount.3ln -sf pcre_study.3 /usr/local/share/man/man3/pcre16_study.3ln -sf pcre_utf16_to_host_byte_order.3 /usr/local/share/man/man3/pcre16_utf16_to_host_byte_order.3ln -sf pcre_version.3 /usr/local/share/man/man3/pcre16_version.3ln -sf pcre_assign_jit_stack.3 /usr/local/share/man/man3/pcre32_assign_jit_stack.3ln -sf pcre_compile.3 /usr/local/share/man/man3/pcre32_compile.3ln -sf pcre_compile2.3 /usr/local/share/man/man3/pcre32_compile2.3ln -sf pcre_config.3 /usr/local/share/man/man3/pcre32_config.3ln -sf pcre_copy_named_substring.3 /usr/local/share/man/man3/pcre32_copy_named_substring.3ln -sf pcre_copy_substring.3 /usr/local/share/man/man3/pcre32_copy_substring.3ln -sf pcre_dfa_exec.3 /usr/local/share/man/man3/pcre32_dfa_exec.3ln -sf pcre_exec.3 /usr/local/share/man/man3/pcre32_exec.3ln -sf pcre_free_study.3 /usr/local/share/man/man3/pcre32_free_study.3ln -sf pcre_free_substring.3 /usr/local/share/man/man3/pcre32_free_substring.3ln -sf pcre_free_substring_list.3 /usr/local/share/man/man3/pcre32_free_substring_list.3ln -sf pcre_fullinfo.3 /usr/local/share/man/man3/pcre32_fullinfo.3ln -sf pcre_get_named_substring.3 /usr/local/share/man/man3/pcre32_get_named_substring.3ln -sf pcre_get_stringnumber.3 /usr/local/share/man/man3/pcre32_get_stringnumber.3ln -sf pcre_get_stringtable_entries.3 /usr/local/share/man/man3/pcre32_get_stringtable_entries.3ln -sf pcre_get_substring.3 /usr/local/share/man/man3/pcre32_get_substring.3ln -sf pcre_get_substring_list.3 /usr/local/share/man/man3/pcre32_get_substring_list.3ln -sf pcre_jit_exec.3 /usr/local/share/man/man3/pcre32_jit_exec.3ln -sf pcre_jit_stack_alloc.3 /usr/local/share/man/man3/pcre32_jit_stack_alloc.3ln -sf pcre_jit_stack_free.3 /usr/local/share/man/man3/pcre32_jit_stack_free.3ln -sf pcre_maketables.3 /usr/local/share/man/man3/pcre32_maketables.3ln -sf pcre_pattern_to_host_byte_order.3 /usr/local/share/man/man3/pcre32_pattern_to_host_byte_order.3ln -sf pcre_refcount.3 /usr/local/share/man/man3/pcre32_refcount.3ln -sf pcre_study.3 /usr/local/share/man/man3/pcre32_study.3ln -sf pcre_utf32_to_host_byte_order.3 /usr/local/share/man/man3/pcre32_utf32_to_host_byte_order.3ln -sf pcre_version.3 /usr/local/share/man/man3/pcre32_version.3make[3]: Leaving directory `/home/flying-bird/software/pcre-8.35'make[2]: Leaving directory `/home/flying-bird/software/pcre-8.35'make[1]: Leaving directory `/home/flying-bird/software/pcre-8.35'flying-bird@flyingbird:~/software/pcre-8.35$ flying-bird@flyingbird:~/software/pcre-8.35$ flying-bird@flyingbird:~/software/pcre-8.35$ cd /usr/local/include/flying-bird@flyingbird:/usr/local/include$ lltotal 100drwxr-xr-x  2 root root  4096  8月 20 20:33 ./drwxr-xr-x 10 root root  4096  4月 24  2012 ../-rw-r--r--  1 root root  6783  8月 20 20:33 pcrecpparg.h-rw-r--r--  1 root root 26529  8月 20 20:33 pcrecpp.h-rw-r--r--  1 root root 31706  8月 20 20:33 pcre.h-rw-r--r--  1 root root  5452  8月 20 20:33 pcreposix.h-rw-r--r--  1 root root  6600  8月 20 20:33 pcre_scanner.h-rw-r--r--  1 root root  6253  8月 20 20:33 pcre_stringpiece.hflying-bird@flyingbird:/usr/local/include$ cd ../libflying-bird@flyingbird:/usr/local/lib$ lltotal 1016drwxr-xr-x  5 root root    4096  8月 20 20:33 ./drwxr-xr-x 10 root root    4096  4月 24  2012 ../-rw-r--r--  1 root root  515794  8月 20 20:33 libpcre.a-rw-r--r--  1 root root   38886  8月 20 20:33 libpcrecpp.a-rwxr-xr-x  1 root root     964  8月 20 20:33 libpcrecpp.la*lrwxrwxrwx  1 root root      19  8月 20 20:33 libpcrecpp.so -> libpcrecpp.so.0.0.0*lrwxrwxrwx  1 root root      19  8月 20 20:33 libpcrecpp.so.0 -> libpcrecpp.so.0.0.0*-rwxr-xr-x  1 root root   44062  8月 20 20:33 libpcrecpp.so.0.0.0*-rwxr-xr-x  1 root root     917  8月 20 20:33 libpcre.la*-rw-r--r--  1 root root   16064  8月 20 20:33 libpcreposix.a-rwxr-xr-x  1 root root     978  8月 20 20:33 libpcreposix.la*lrwxrwxrwx  1 root root      21  8月 20 20:33 libpcreposix.so -> libpcreposix.so.0.0.2*lrwxrwxrwx  1 root root      21  8月 20 20:33 libpcreposix.so.0 -> libpcreposix.so.0.0.2*-rwxr-xr-x  1 root root   20461  8月 20 20:33 libpcreposix.so.0.0.2*lrwxrwxrwx  1 root root      16  8月 20 20:33 libpcre.so -> libpcre.so.1.2.3*lrwxrwxrwx  1 root root      16  8月 20 20:33 libpcre.so.1 -> libpcre.so.1.2.3*-rwxr-xr-x  1 root root  366755  8月 20 20:33 libpcre.so.1.2.3*drwxr-xr-x  2 root root    4096  8月 20 20:33 pkgconfig/drwxrwsr-x  4 root staff   4096  8月 13 22:19 python2.7/drwxrwsr-x  3 root staff   4096  8月 13 22:19 python3.4/flying-bird@flyingbird:/usr/local/lib$ cd ../binflying-bird@flyingbird:/usr/local/bin$ lltotal 284drwxr-xr-x  2 root root   4096  8月 20 20:33 ./drwxr-xr-x 10 root root   4096  4月 24  2012 ../-rwxr-xr-x  1 root root   2363  8月 20 20:33 pcre-config*-rwxr-xr-x  1 root root  89152  8月 20 20:33 pcregrep*-rwxr-xr-x  1 root root 186890  8月 20 20:33 pcretest*flying-bird@flyingbird:/usr/local/bin$ cd ../share/ca-certificates/ doc/             fonts/           man/             sgml/            xml/             flying-bird@flyingbird:/usr/local/bin$ cd ../share/doc/flying-bird@flyingbird:/usr/local/share/doc$ lltotal 12drwxr-xr-x 3 root root 4096  8月 20 20:33 ./drwxr-xr-x 8 root root 4096  8月 20 20:33 ../drwxr-xr-x 3 root root 4096  8月 20 20:33 pcre/flying-bird@flyingbird:/usr/local/share/doc$ cd pcre/flying-bird@flyingbird:/usr/local/share/doc/pcre$ lltotal 956drwxr-xr-x 3 root root   4096  8月 20 20:33 ./drwxr-xr-x 3 root root   4096  8月 20 20:33 ../-rw-r--r-- 1 root root    851  8月 20 20:33 AUTHORS-rw-r--r-- 1 root root 264114  8月 20 20:33 ChangeLog-rw-r--r-- 1 root root     95  8月 20 20:33 COPYINGdrwxr-xr-x 2 root root   4096  8月 20 20:33 html/-rw-r--r-- 1 root root   3099  8月 20 20:33 LICENCE-rw-r--r-- 1 root root  27924  8月 20 20:33 NEWS-rw-r--r-- 1 root root   3146  8月 20 20:33 pcre-config.txt-rw-r--r-- 1 root root  42257  8月 20 20:33 pcregrep.txt-rw-r--r-- 1 root root  54244  8月 20 20:33 pcretest.txt-rw-r--r-- 1 root root 504077  8月 20 20:33 pcre.txt-rw-r--r-- 1 root root  44896  8月 20 20:33 READMEflying-bird@flyingbird:/usr/local/share/doc/pcre$ 

4. 正则表达式资料

在之前的python系列(此系列未完待续)中,有一篇介绍了正则表达式:Python入门教程-12 正则表达式 ,其中推荐了学习正则表达式的书籍。

0 0
原创粉丝点击