какой юнит работает с регулярными выражениями?
в смысле чем можно парсить текст?
Модератор: Модераторы
regexpr
Attid писал(а):
- Код: Выделить всё
regexpr
debi12345 писал(а):Attid писал(а):
- Код: Выделить всё
regexpr
Слабоватый (хотя и компактный) модуль, самое страшное -не умеет работать с юникодом.
Поэтому пользуюсь 100% оснащенным TRegExpr с адресов http://anso.da.ru/ или http://anso.virtualave.net/
debi12345 писал(а):Attid писал(а):
- Код: Выделить всё
regexpr
Слабоватый (хотя и компактный) модуль, самое страшное -не умеет работать с юникодом.
Поэтому пользуюсь 100% оснащенным TRegExpr с адресов http://anso.da.ru/ или http://anso.virtualave.net/
uses
Windows;
uses
{$IFDEF Linux}
Unix;
{$ENDIF}
{$IFDEF Win32}
Windows;
{$ENDIF}
Vlad-55 писал(а):По указанным адресам ошибка 404. Нашел модуль здесь.
uses
synregexpr,
...
procedure TForm1.Button1Click(Sender:TObject);
var RegExpr: TRegExpr;
RegExprStr: string;
begin
RegExprStr:='^ko(?:t|shka)'; // группировка без обратной связи
//RegExprStr:='^ko(t|shka)'; // без группировки работает %(
RegExpr:= tRegExpr.Create;
RegExpr.Expression:= RegExprStr;
if RegExpr.Exec('kot i koshka') // здесь валится
then showmessage(
'RegExpr.Expression = '+(RegExpr.Expression)+#13#13+
'RegExpr.SubExprMatchCount = '+inttostr(RegExpr.SubExprMatchCount)+#13+
'RegExpr.MatchPos[0] = '+inttostr(RegExpr.MatchPos[0])+#13+
'RegExpr.MatchLen[0] = '+inttostr(RegExpr.MatchLen[0])+#13+
'');
FreeAndNil(RegExpr);
end;
dunin писал(а):...
Вопрос: что не так делаю?![]()
Спасибо.
Вопрос к сообществу: кто-нибудь знает альтернативные юниты/библиотеки для использования регулярных выражений?
Odyssey писал(а):Ещё есть обёртка PCRE для Delphi, но её придётся сначала портировать на FPC, и она потянет за собой динамическую библиотеку. И ещё лицензию на саму обёртку нужно уточнить. Но потенциально это полная поддержка perl-совместимых регулярных выражений.
TPerlRegEx is a Delphi VCL wrapper around the open source PCRE library, which implements Perl-Compatible Regular Expressions.
The supplied pcrelib.dll contains PCRE 7.9, compiled with Unicode support.
The supplied OBJ files contain PCRE 7.9, compiled with Unicode support.
By default, the component uses the DLL. Using the OBJ files can trigger an internal compiler error, particularly when installing the component into a package. You can use the OBJ files by editing the compiler directives at the top of the pcre.pas file.
For more information about PCRE, please visit http://www.regular-expressions.info/pcre.html
For more information about regular expressions in general, please visit http://www.regular-expressions.info/
You can download the latest version of TPerlRegEx at http://www.regular-expressions.info/delphi.html
TPerlRegEx is licensed under the Mozilla Public License, version 1.1.
To install this component into Delphi, open the .dpk file for your Delphi version, compile it, and install it into the IDE. The TPerlRegEx component will appear on the JGsoft page in the component palette.
Alternatively, you can create a new package or add the component to an existing package. Simply add the files PerlRegEx.pas and pcre.pas to the package.
If you prefer to instantiate TPerlRegEx at runtime instead of dropping it on a form, you don't need to install its package into the Delphi IDE. Simply add PerlRegEx to the uses clause of the units in which you want to use it. There's no need to add the pcre unit to the uses clause. This unit is used internally by TPerlRegEx.
const
{$IFDEF MSWINDOWS}
libpcremodulename = 'pcrelib.dll';
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
libpcremodulename = 'libpcre.so.0';
{$ENDIF UNIX}
Вернуться в Free Pascal Compiler
Сейчас этот форум просматривают: Google [Bot] и гости: 3