public delegate void MyEventHandler(object sender, DataGridViewCellEventArgs e);
public event MyEventHandler SomethingHappened;
private void dataGridViewCargo_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
DataGridViewRow rowID = this.dataGridViewCargo.Rows[e.RowIndex];
cargoDisplayMessageIdTextBox.Text = rowID.Cells["iDDataGridViewTextBoxColumn"].Value.ToString();
DataGridViewRow rowSender = this.dataGridViewCargo.Rows[e.RowIndex];
cargoDisplaySubjectTextBox.Text = rowSender.Cells["subjectDataGridViewTextBoxColumn"].Value.ToString();
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
Invoke(new MyEventHandler(SomethingHappened));
return base.ProcessCmdKey(ref msg, keyData);
}
我有这个正则表达式,我基本上试着说字母字符可以是最小4个字符然后是1或2位数字,但是整个字符不应该超过8个字符
示例:
^([A-Za-z]{4,}(\d{1,2})){,8}$
我的正则表达式出了什么问题?
答案 0 :(得分:1)
您可以使用基于前瞻性的正则表达式:
\b(?=[a-zA-Z\d]{4,8}\b)[a-zA-Z]{4,}\d{1,2}\b
RegEx分手:
\b # word boundary
(?=[a-zA-Z\d]{4,8}\b) # lookahead to allow between 4 to 8 alpha-numeric chars
[a-zA-Z]{4,} # match minimum 4 alphabets
\d{1,2} # match 1 or 2 digits
\b # word boundary
答案 1 :(得分:1)
表达式末尾的{,8}
允许整个前面的正则表达式最多复制8次。您可能想尝试投入两层正则表达式 - 一个用于检查每个标准:
^[A-Za-z]{4,}(\d{1,2})$
然后通过
提供输出^.{,8}$