.NET で、空間内のポイントを入力として検証しようとしていますDataGridView
。への入力は、次のDataGridViewTextBoxCell
形式にする必要があります。
[1.0, 1.0, 1.0]
上記は X、Y、Z 軸を表します (または単にである場合1.0
もあります)。また、開き括弧と閉じ括弧も含める必要があります。
これは位置であるため、負または正の可能性があり、小数点以下の桁数は n です。0.1
.1
正規表現を探している場合は、次のようになります。
^ // The string should start with the left bracer
\[ // left bracer
([-+]?[0-9]*\.?[0-9]+), // first float value followed by a virgule, this is matched
([-+]?[0-9]*\.?[0-9]+), // second float value followed by a virgule, this is matched
([-+]?[0-9]*\.?[0-9]+) // third float value, this is matched
\] // right bracer
$ // The string should end with the right bracer
コメントがなければ、次のようになります。
^\[([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)\]$
正規表現でスペースを無視する場合は、各要素の間に \s* を追加できます。
^\s*\[\s*([-+]?[0-9]*\.?[0-9]+)\s*,\s*([-+]?[0-9]*\.?[0-9]+)\s*,\s*([-+]?[0-9]*\.?[0-9]+)\s*\]\s*$