Help with Regex Validation lazarus / 62-General ---------------------------------------------------------------------- jorge_mosquera · 2024-02-13 15:04 Hello, please help. I need to implement data validation using Regex, for example to ensure that only one of these options is entered: a- Only numbers b- Only letters without space c- Only letters with space d- Date in dd/mm/yyyy format For example, I am using this code to validate only numbers, but it returns true if I enter numbers, numbers plus letters, when what I expect is that when entering a character other than numbers, it returns an error Procedure TForm1.Button1Click(Sender: TObject); var   Regex : TRegExpr;   band : boolean; Begin   Regex := TRegExpr.Create;   case RadioGroup1.ItemIndex of    0 : Regex.Expression := '\d+';   End;   if Regex.Exec(LabeledEdit1.Text)  then    showmessage('Yes')   else     showmessage('no'); end; Regards ---------------------------------------------------------------------- Fibonacci · 2024-02-13 15:13 Expression is invalid. It finds any decimal inside String, you need to make sure there is nothing else before and after "\d", you do this using ^ and $. ^\d+$ ---------------------------------------------------------------------- Martin_fr · 2024-02-13 15:47 There are sites like https://regex101.com/ that can help. You can test your regex there, and you get an explanation of what it does. Depending on what feature you need, they may not all be in the TRegExpr that comes with current fpc. The upstream project is ahead and offers more. https://github.com/andgineer/TRegExpr Doc: https://github.com/andgineer/TRegExpr/blob/master/docs/tregexpr.rst