Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- ParseRegexPattern: String = '(?<Sign>[+-]?)((?<BaseHex>\$)|(?<BaseOct>0))?';
- var
- ParseRegex: TRegEx;
- sMatch: TMatch;
- numberBase: UInt32;
- checkFormat: Boolean;
- begin
- ParseRegex := TRegEx.Create(ParseRegexPattern, [roCompiled]);
- if (sMatch.Groups['Sign'].Value = '-') then
- begin
- negative := True;
- end;
- if (smatch.Groups['BaseHex'].Length <> 0) then
- begin
- if (checkFormat) then
- begin
- // $ before the number - this is hex number
- numberBase := UInt32(16);
- end
- else
- begin
- // This is an error
- raise Exception.Create(Strings.ParseInvalidChar);
- end
- end
- else
- if (smatch.Groups['BaseOct'].Length <> 0) then
- begin
- if (checkFormat) then
- begin
- // 0 before the number - this is octal number
- numberBase := UInt32(8);
- end;
- stringNotEmpty := True;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement