mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 12:26:58 +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.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/src/old/regexpr.pp svneol=native#text/plain
|
||||
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
|
||||
--------------------------------------------------------------}
|
||||
|
||||
{$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;
|
||||
begin
|
||||
{$IFDEF UniCode}
|
||||
if Ch >= #128
|
||||
then Result := Ch
|
||||
else
|
||||
begin
|
||||
{$IFDEF FPC}
|
||||
Result := AnsiUpperCase(Ch)[1];
|
||||
if Result = Ch then
|
||||
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}
|
||||
begin
|
||||
Result := {$IFDEF FPC}AnsiUpperCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharUpper (PChar (Ch))){$ELSE}REChar (toupper (integer (Ch))){$ENDIF} {$ENDIF};
|
||||
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
|
||||
{$ENDIF}
|
||||
end; { of function TRegExpr.InvertCaseFunction
|
||||
--------------------------------------------------------------}
|
||||
|
||||
function TRegExpr.GetExpression : RegExprString;
|
||||
@ -3886,8 +3907,7 @@ begin
|
||||
smodeOneLower, smodeAllLower:
|
||||
begin
|
||||
Ch := p0^;
|
||||
if Ch < #128 then
|
||||
Ch := AnsiLowerCase(Ch)[1];
|
||||
Ch := AnsiLowerCase(Ch)[1];
|
||||
ResultPtr^ := Ch;
|
||||
if Mode = smodeOneLower then
|
||||
Mode := smodeNormal;
|
||||
@ -3895,8 +3915,7 @@ begin
|
||||
smodeOneUpper, smodeAllUpper:
|
||||
begin
|
||||
Ch := p0^;
|
||||
if Ch < #128 then
|
||||
Ch := AnsiUpperCase(Ch)[1];
|
||||
Ch := AnsiUpperCase(Ch)[1];
|
||||
ResultPtr^ := Ch;
|
||||
if Mode = smodeOneUpper then
|
||||
Mode := smodeNormal;
|
||||
|
@ -1,4 +1,4 @@
|
||||
{define unicode}
|
||||
{$define unicode}
|
||||
{$macro on}
|
||||
{$define regexpr:=uregexpr}
|
||||
{$I regexpr.pas}
|
||||
|
Loading…
Reference in New Issue
Block a user