Может кто-то помочь мне с этими 2 регулярным выражением:Смысл простого регулярного выражения
First: "^\\s+|\\s+$"
Second: "\\s{2,}"
Может кто-то помочь мне с этими 2 регулярным выражением:Смысл простого регулярного выражения
First: "^\\s+|\\s+$"
Second: "\\s{2,}"
Посмотрите на это или поиск с помощью Google. Не сложно интерпретировать эти регулярные выражения.
http://www.regular-expressions.info/reference.html#
Например:
\ S матчи {пробелы 2} означает, 2 из него или более
Почему бы не использовать DAT инструмент может 'документ' выражения? Это может помочь вам понять их.
Использование RegexBuddy (Paid однако, на мой взгляд лучший инструмент доступен) выражение документировано, как показано ниже:
// ^\s+|\s+$
//
// Options:^and $ match at line breaks
//
// Match either the regular expression below (attempting the next alternative only if this one fails) «^\s+»
// Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
// Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s+»
// Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
// Or match regular expression number 2 below (the entire match attempt fails if this one fails to match) «\s+$»
// Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s+»
// Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
// Assert position at the end of a line (at the end of the string or before a line break character) «$»
Посмотрите http://www.regular-expressions.info/ –
Вы можете экспериментировать с ними на http://gskinner.com/RegExr/ – JefClaes
JefClaes, отличная ссылка! – DixieFlatline