📄 regexpr.pas
字号:
{$B-}
unit RegExpr;
(*
TRegExpr library
Regular Expressions for Delphi
v. 0.942
Author:
Andrey V. Sorokin
St-Petersburg
Russia
anso@mail.ru, anso@usa.net
http://anso.da.ru
http://anso.virtualave.net
This library is derived from Henry Spencer sources.
I translated the C sources into Object Pascal,
implemented object wrapper and some new features.
Many features suggested or partially implemented
by TRegExpr's users (see Gratitude below).
---------------------------------------------------------------
Legal issues
---------------------------------------------------------------
Copyright (c) 1999-00 by Andrey V. Sorokin <anso@mail.ru>
This software is provided as it is, without any kind of warranty
given. Use it at your own risk.
You may use this software in any kind of development, including
comercial, redistribute, and modify it freely, under the
following restrictions :
1. The origin of this software may not be mispresented, you must
not claim that you wrote the original software. If you use
this software in any kind of product, it would be appreciated
that there in a information box, or in the documentation would
be an acknowledgmnent like this
Partial Copyright (c) 2000 by Andrey V. Sorokin
2. You may not have any income from distributing this source
to other developers. When you use this product in a comercial
package, the source may not be charged seperatly.
---------------------------------------------------------------
Legal issues for the original C sources:
---------------------------------------------------------------
* Copyright (c) 1986 by University of Toronto.
* Written by Henry Spencer. Not derived from licensed software.
*
* Permission is granted to anyone to use this software for any
* purpose on any computer system, and to redistribute it freely,
* subject to the following restrictions:
* 1. The author is not responsible for the consequences of use of
* this software, no matter how awful, even if they arise
* from defects in it.
* 2. The origin of this software must not be misrepresented, either
* by explicit claim or by omission.
* 3. Altered versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
---------------------------------------------------------------
Gratitudes
---------------------------------------------------------------
Guido Muehlwitz
found and fixed ugly bug in big string processing
Stephan Klimek
testing in CPPB and suggesting/implementing many features
Steve Mudford
implemented Offset parameter
Martin Baur
usefull suggetions
Yury Finkel
Implemented UniCode support, found and fixed some bugs
Ralf Junker
Implemented some features, many optimization suggestions
Filip Jirs醟 and Matthew Winter (wintermi@yahoo.com)
Help in Implementation non-greedy mode
Kit Eason
many examples for introduction help section
Juergen Schroth
bug hunting and usefull suggestions
And many others - for big work of bug hunting !
I am still looking for person who can help me to translate
this documentation into other languages (especially German)
---------------------------------------------------------------
To do
---------------------------------------------------------------
-=- VCL-version of TRegExpr - for dummies ;) and TRegExprEdit
(replacement for TMaskEdit).
Actually, I am writing non-VCL aplications (with web-based
interfaces), so I don't need VCL's TRegExpr for myself.
Will it be really usefull ?
-=- working with pascal-style string.
Now pascal-strings converted into PChar, so
you can't find r.e. in strings with #0 -chars.
(suggested by Pavel O).
-=- put precalculated lengths into EXACTLY[CI] !
-=- fInputString as string (suggested by Ralf Junker)
-=- Add regstart optimization for case-insensitive mode ?
Or complitely remove because FirstCharSet is faster ?
-=- "Russian Ranges" --> National ranges (use property WordChars ?
for ordering letters in ranges by its order in WirdsChars if modifier /r is On)
-=- FirstCharSet as array [#0 .. #255] of REChar ?
(2x faster then set of REChar)
-=- p-code optimization (remove BRANCH-to-EEND, COMMENT, BACK(?)
merge EXACTLY etc).
-=- !!!!!!!! bug found by Lars Karlslund
"If I do '(something|^$)' on '' I get false (which is wrong ...)."
-=- There are not special command for files (Johan Smit).
I need your suggestions !
What are more importent in this list ?
Did I forget anything ?
---------------------------------------------------------------
History
---------------------------------------------------------------
Legend:
(+) added feature
(-) fixed bug
(^) upgraded implementation
v. 0.942 2001.02.12
-=- (-) Range-check error in DEMO-project (due to bug in
RegExprSubExpressions), Thanks to Juergen Schroth
-=- (^) RegExprSubExpressions - added error codes for "unclosed "[" error
-=- (^) Help file bug fixing
v. 0.941 2001.02.01
-=- (^) Attension! Behaviour of '\w', '\W' was changed! Now it really
match alphanum characters and '_' as described in documentation,
not only alpha as it was before. Thanks to Vadim Alexandrov.
If You want to restore previous behaviour, reassign
RegExprWordChars (exclude '0123456789' from it).
-=- (+) Full compatible with recommended at unicode.org implementation
of modifier /m, including DOS-styled line separators (\r\n) mixed
with Unix styled (\n) - see properties LineSeparators, LinePairedSeparator
-=- (^) Attension! Behaviour of '.' was changed! Now if modifier /s is off
it doesn't match all chars from LineSeparators and LinePairedSeparator (by
default \r and \n)
-=- (^) Attension! To prevent unneeded recompilation of r.e., now assignment
to Expression or changing modifiers doesn't cause immidiate [re]compilation.
So, now You don't get exception while assigning wrong expression, but can
get exception while calling Exec[Next], Substitute, Dump, etc if there
are errors in Expression or other properties.
-=- (+) Non-greedy style iterators (like '*?'), modifier /g.
Implemented with help from Matthew Winter and Filip Jirs醟
-=- (+) /x modifier (eXtended syntax - allow formating r.e., see description
in the help)
-=- (+) Procedure Compile to [re]compile r.e. Usefull for GUI r.e. editors
and so on (to check all properties validity).
-=- (+) FAQ in documentation. I am too lazy to answer to the same
questions again and again :( Please, read the FAQ before sending
question to me!
-=- (^) DEMO project have been significantly improved. Now this is the
real r.e. debugger! Thanks to Jon Smith for his ideas.
-=- (+) function RegExprSubExpressions, usefull for GUI editors of
r.e. (see example of using in TestRExp.dpr project)
-=- (+) HyperLinkDecorator unit - practical example of TRegExpr
using (see description in the help file)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -