// Options is a list box
private void MoveUpButton_Click(object sender,EventArgs e) {
int index = Options.SelectedIndex;
if (index <= 0) return;
string item = (string)Options.Items[index - 1];
Options.Items.RemoveAt(index - 1);
Options.Items.Insert(index,item);
selectedIndexChanged(null,null);
}
private void MoveDnButton_Click(object sender,EventArgs e) {
int index = Options.SelectedIndex;
if (index + 1 >= Options.Items.Count) return;
string item = (string)Options.Items[index];
Options.Items.RemoveAt(index);
Options.Items.Insert(index + 1,item);
Options.SelectedIndex = index + 1;
}
// sent when user makes a selection or when he moves an item up or down
private void selectedIndexChanged(object sender,EventArgs e) {
int index = Selected.SelectedIndex;
MoveUpButton.Enabled = index > 0;
MoveDnButton.Enabled = index + 1 < Selected.Items.Count;
}
Вот хороший онлайн-инструмент для регулярных выражений: www.gskinner.com/RegExr/
Creating regular expressions without having any clue about them doesn't work. But you can make use of software that helps you create them. I heard that regexbuddy should be quite good.
EDIT
Reasons why creating regexes from arbitrary strings cannot work can be found in the answer to this question
Expresso has a regex GUI builder.
Но я бы рекомендовал потратить немного времени и изучить регулярные выражения - вы сможете создавать выражения намного быстрее, чем с помощью графического интерфейса помощника-строителя
Правка: Но он все равно не будет читать ваши мысли. Вам нужно построить регулярное выражение по частям ... в том смысле, что мне нужно 3 цифры, затем - и так далее ... Он не может догадаться, что вам нужен номер телефона с соответствующей строкой
I'm also a fan of RegexBuddy, but if you're working on a tight budget you can also use the open source (and free) utility called Kodos. It was originally designed for debugging and creating regular expressions for Python, but you can use it to validate any regular expression.
Of course, it will still rely on you actually knowing how to construct the regex, but at least you can use it to validate or test what you have.
The human brain will create better and more readable regexes than any RegexBuddy. Regardless of how much a piece of software may help you develop faster regexes, there are several problems you'll have with these regexes:
In the end, learning regular expressions will make you a better programmer - you'll be able to read other people's code and understand what it does, as well as being able to write your own regexes on the fly, which will usually be faster than stopping your coding workflow, turning to some external program, coming up with a list of test cases that should pass or fail, and then copying and pasting the resulting generated regex into your code without knowing what it does.
Regex Coach мне очень помог - он поддерживает почти все тонкости регулярных выражений; вы видите в реальном времени, как ваши модификации работают со строкой; также имеет визуальное представление дерева синтаксического анализа.
Если вы используете Eclipse, то Regex Util от Сергея Евдокимова - одно удовольствие. Он находится прямо в вашей среде IDE, поэтому вы не потеряете его и обеспечивает мгновенную обратную связь по совпадениям. Затем он выполняет за вас все экранирование / отмену экранирования, пока вы копируете и вставляете его туда и обратно в свой код.
Мне нравится подсветка и дополнительные функции в RegexPal . Это бесплатный веб-инструмент, в котором легко найти краткий справочник. Вы даже заметите внизу, что они рекомендуют RegexBuddy для большей мощности, но вы по-прежнему найдете функциональность RegexBuddy в веб-приложении.