mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 06:29:38 +02:00
parent
3c18e12cc7
commit
962391621f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7257,6 +7257,7 @@ packages/regexpr/examples/Makefile.fpc svneol=native#text/plain
|
|||||||
packages/regexpr/examples/splitwords.lpi svneol=native#text/plain
|
packages/regexpr/examples/splitwords.lpi svneol=native#text/plain
|
||||||
packages/regexpr/examples/splitwords.pp svneol=native#text/plain
|
packages/regexpr/examples/splitwords.pp svneol=native#text/plain
|
||||||
packages/regexpr/examples/testreg1.pp svneol=native#text/plain
|
packages/regexpr/examples/testreg1.pp svneol=native#text/plain
|
||||||
|
packages/regexpr/examples/testure.pp svneol=native#text/plain
|
||||||
packages/regexpr/fpmake.pp svneol=native#text/plain
|
packages/regexpr/fpmake.pp svneol=native#text/plain
|
||||||
packages/regexpr/src/old/regexpr.pp svneol=native#text/plain
|
packages/regexpr/src/old/regexpr.pp svneol=native#text/plain
|
||||||
packages/regexpr/src/oldregexpr.pp svneol=native#text/pascal
|
packages/regexpr/src/oldregexpr.pp svneol=native#text/pascal
|
||||||
|
23
packages/regexpr/examples/testure.pp
Normal file
23
packages/regexpr/examples/testure.pp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
program testure;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
{$H+}
|
||||||
|
{$CODEPAGE UTF8}
|
||||||
|
|
||||||
|
uses
|
||||||
|
cwstring, Classes, SysUtils, uregexpr;
|
||||||
|
|
||||||
|
var
|
||||||
|
r: TRegExpr;
|
||||||
|
s, s2: UTF8String;
|
||||||
|
begin
|
||||||
|
r:= TRegExpr.create;
|
||||||
|
r.Expression:= '.+';
|
||||||
|
s:= 'pro про';
|
||||||
|
s2:= r.Replace(s, '\U$0', true);
|
||||||
|
Writeln(Format('Upcase of "%s" -> "%s"', [s, s2]));
|
||||||
|
|
||||||
|
s:= 'PRO ПРО';
|
||||||
|
s2:= r.Replace(s, '\L$0', true);
|
||||||
|
Writeln(Format('Lowcase of "%s" -> "%s"', [s, s2]));
|
||||||
|
end.
|
@ -1228,19 +1228,40 @@ destructor TRegExpr.Destroy;
|
|||||||
end; { of destructor TRegExpr.Destroy
|
end; { of destructor TRegExpr.Destroy
|
||||||
--------------------------------------------------------------}
|
--------------------------------------------------------------}
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
{$IFDEF UNICODE}
|
||||||
|
function AnsiUpperCase(const s: RegExprString): RegExprString;inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=WideUpperCase(S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function AnsiLowerCase(const s: RegExprString): RegExprString;inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=WideLowerCase(S);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
class function TRegExpr.InvertCaseFunction (const Ch : REChar) : REChar;
|
class function TRegExpr.InvertCaseFunction (const Ch : REChar) : REChar;
|
||||||
begin
|
begin
|
||||||
{$IFDEF UniCode}
|
{$IFDEF FPC}
|
||||||
if Ch >= #128
|
Result := AnsiUpperCase(Ch)[1];
|
||||||
then Result := Ch
|
if Result = Ch then
|
||||||
else
|
Result := AnsiLowerCase(Ch)[1];
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF SYN_WIN32}
|
||||||
|
Result := REChar (CharUpper (PChar (Ch)));
|
||||||
|
if Result = Ch then
|
||||||
|
Result := REChar (CharLower (PChar (Ch)));
|
||||||
|
{$ELSE}
|
||||||
|
Result := REChar (toupper (integer (Ch)));
|
||||||
|
if Result = Ch then
|
||||||
|
Result := REChar(tolower (integer (Ch)));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
begin
|
{$ENDIF}
|
||||||
Result := {$IFDEF FPC}AnsiUpperCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharUpper (PChar (Ch))){$ELSE}REChar (toupper (integer (Ch))){$ENDIF} {$ENDIF};
|
end; { of function TRegExpr.InvertCaseFunction
|
||||||
if Result = Ch
|
|
||||||
then Result := {$IFDEF FPC}AnsiLowerCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharLower (PChar (Ch))){$ELSE}REChar(tolower (integer (Ch))){$ENDIF} {$ENDIF};
|
|
||||||
end;
|
|
||||||
end; { of function TRegExpr.InvertCaseFunction
|
|
||||||
--------------------------------------------------------------}
|
--------------------------------------------------------------}
|
||||||
|
|
||||||
function TRegExpr.GetExpression : RegExprString;
|
function TRegExpr.GetExpression : RegExprString;
|
||||||
@ -3886,8 +3907,7 @@ begin
|
|||||||
smodeOneLower, smodeAllLower:
|
smodeOneLower, smodeAllLower:
|
||||||
begin
|
begin
|
||||||
Ch := p0^;
|
Ch := p0^;
|
||||||
if Ch < #128 then
|
Ch := AnsiLowerCase(Ch)[1];
|
||||||
Ch := AnsiLowerCase(Ch)[1];
|
|
||||||
ResultPtr^ := Ch;
|
ResultPtr^ := Ch;
|
||||||
if Mode = smodeOneLower then
|
if Mode = smodeOneLower then
|
||||||
Mode := smodeNormal;
|
Mode := smodeNormal;
|
||||||
@ -3895,8 +3915,7 @@ begin
|
|||||||
smodeOneUpper, smodeAllUpper:
|
smodeOneUpper, smodeAllUpper:
|
||||||
begin
|
begin
|
||||||
Ch := p0^;
|
Ch := p0^;
|
||||||
if Ch < #128 then
|
Ch := AnsiUpperCase(Ch)[1];
|
||||||
Ch := AnsiUpperCase(Ch)[1];
|
|
||||||
ResultPtr^ := Ch;
|
ResultPtr^ := Ch;
|
||||||
if Mode = smodeOneUpper then
|
if Mode = smodeOneUpper then
|
||||||
Mode := smodeNormal;
|
Mode := smodeNormal;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{define unicode}
|
{$define unicode}
|
||||||
{$macro on}
|
{$macro on}
|
||||||
{$define regexpr:=uregexpr}
|
{$define regexpr:=uregexpr}
|
||||||
{$I regexpr.pas}
|
{$I regexpr.pas}
|
||||||
|
Loading…
Reference in New Issue
Block a user