资源简介
正则表达式是一个很强的工具,可以在你的软件中增强查找、替换、匹配等功能。附件中封装了Henry Spencer的regex library源码,有说明和范例,纯C可移值,简单易用。
代码片段和文件信息
/**
* @file JRegex.c
*
* @brief Regular expression functions
*
* Original code by Henry Spencer
* Henry Spencer‘s regex library
* ftp://ftp.zoo.toronto.edu/pub/bookregexp.{tar|shar}
* or http://www.arglist.com/regex/files/regexp.old.tar.Z
*
* Wrapped by JoStudio
*
*
*/
//=================Start of wapped Henry Spencer‘s regex library ==============
// Functions written by Henry Spencer
/*
* regmagic.h regcomp and regexec are include
*/
#include
#include
#include
#include
///#include
//==== start of “regex.h“ =======
/*
* Definitions etc. for regexp(3) routines.
*
* Caveat: this is V8 regexp(3) [actually a reimplementation thereof]
* not the System V one.
*/
#define NSUBEXP 10
typedef struct regexp {
char *startp[NSUBEXP];
char *endp[NSUBEXP];
char regstart; /* Internal use only. */
char reganch; /* Internal use only. */
char *regmust; /* Internal use only. */
int regmlen; /* Internal use only. */
char program[1]; /* Unwarranted chumminess with compiler. */
} regexp;
regexp *regcomp(const char *re);
int regexec(regexp *rp const char *s);
void regsub(const regexp *rp const char *src char *dst);
void regerror(char *message);
//==== end of “regex.h“ =======
///#include
//==== start of “regmagic.h“ =======
/*
* The first byte of the regexp internal “program“ is actually this magic
* number; the start node begins in the second byte.
*/
#define MAGIC 0234
//==== end of “regmagic.h“ =======
//==== start of “regexp.c“ =======
/*
* The “internal use only“ fields in regexp.h are present to pass info from
* compile to execute that permits the execute phase to run lots faster on
* simple cases. They are:
*
* regstart char that must begin a match; ‘\0‘ if none obvious
* reganch is the match anchored (at beginning-of-line only)?
* regmust string (pointer into program) that match must include or NULL
* regmlen length of regmust string
*
* Regstart and reganch permit very fast decisions on suitable starting points
* for a match cutting down the work a lot. Regmust permits fast rejection
* of lines that cannot possibly match. The regmust tests are costly enough
* that regcomp() supplies a regmust only if the r.e. contains something
* potentially expensive (at present the only such thing detected is * or +
* at the start of the r.e. which can involve a lot of backup). Regmlen is
* supplied because the test in regexec() needs it and regcomp() is computing
* it anyway.
*/
/*
* Structure for regexp “program“. This is essentially a linear encoding
* of a nondeterministic finite-state machine (aka syntax charts or
* “railroad normal form“ in parsing technology). Each node is an opcode
* plus a “next“ pointer possibly plus an operand. “Next“ pointers of
* all nodes except BRANCH implement concatenation; a “next“ pointer with
* a BRANCH on both ends of it is connecting two alternatives. (Here we
* have one of the su
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 40610 2011-06-26 13:59 JRegex.c
文件 4420 2011-06-26 13:59 JRegex.h
文件 3665 2011-06-26 14:30 test.c
文件 6853 2011-06-26 14:37 002 正则表达式(regex)及C语言实现.txt
----------- --------- ---------- ----- ----
55548 4
相关资源
- 数据结构各种算法实现(C++模板),
- 基于C51与1602液晶显示屏的万年历电子
- 扩展欧几里德算法c++代码
- c++编写的经典小游戏
- VC远程控制代码集合
- [BUPT]面向对象程序设计C++ - 平时作业
- MFC基于对话框游戏 打字游戏1.0V
- 循环冗余校验码(CRC)计算源代码合
- opencv版俄罗斯方块源码
- 坦克大战 C++
- c++ 课程设计_中国象棋
- 自绘CListCtrl聊天列表MFC
- c++做的坦克大战源码
- MFC与坦克大战代码
- Bmp图像处理.zip
- c++使用ffmpeg把h264/h265和mp3写入mp4文件
- ACE技术内幕:深入解析ACE架构设计与
- c语言 Windows_程序设计_第五版
- 信息学奥赛普及组2011年到2016年C++真题
- C++实现的斗地主游戏
- 常用算法程序集C语言描述 第三版pd
- C++ 游戏疯狂的赛车
- 游戏开发 c语言 程序设计 飞机大战
- 网络游戏脱机外挂(辅助)C++源码(
- 简易图书管理系统C语言
- VC++数字图像处理典型算法及实现
- 编译原理课程设计-C语言子集编译器
- 《面向对象的程序设计语言——C++》
- 银行账户管理系统C++
- VC++酒店客房管理系统 MFC
评论
共有 条评论