Цитата(ksnk @ 3.5.2007, 10:06 ) | | А знаки + в регулярном выражении что по твоему должны означать? |
одно и более повторений
Интересно всё-таки посмотреть на строку, которую ловят таким регулярным.
| Код | /^([А-Я]+[а-я]*)([-]{1}[А-Я]+[а-я]*|[а-я]*)$/
/* Assert position at the start of the string «^» Match the regular expression below and capture its match into backreference number 1 «([А-Я]+[а-я]*)» Match a single character in the range between "А" and "Я" «[А-Я]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match a single character in the range between "а" and "я" «[а-я]*» Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» Match the regular expression below and capture its match into backreference number 2 «([-]{1}[А-Я]+[а-я]*|[а-я]*)» Match either the regular expression below (attempting the next alternative only if this one fails) «[-]{1}[А-Я]+[а-я]*» Match the character "-" «[-]{1}» Exactly 1 times «{1}» Match a single character in the range between "А" and "Я" «[А-Я]+» Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» Match a single character in the range between "а" and "я" «[а-я]*» Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» Or match regular expression number 2 below (the entire group fails if this one fails to match) «[а-я]*» Match a single character in the range between "а" and "я" «[а-я]*» Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*» Assert position at the end of the string (or before the line break at the end of the string, if any) «$» */
|
|