
Hi, im looking trying to make a field text[6] with an allowed input format saying 2 letters, a hypen and the 3 letters/numbers.
Example: "DE-AB1"
How do I make the Onvalidate code?
Do I need to make 3 variables:
1. 2 letters
2. The hypen
3. 3 letters/numbers
Or can I make it all in one go?
Have tried some different ways but it wont work.
Thanks in advance.
If you need a simple pattern (adjust as needed)
var
Regex: Codeunit Regex;
Pattern,
Value : Text;
begin
Value := 'AA-AAA';
Pattern := '[A-Z]{2}\-[0-9,A-Z]{3}';
if Regex.IsMatch(Value, Pattern, 0) then
Message('Match')
else
Message('No Match');
end;