К сожалению, это была простая проблема CSS.
Все компоненты, отображаемые на выходе маршрутизатора, используют div, чтобы обернуть компонент. Мне нужно было добавить следующее:
position: fixed;
blockquote>После этого анимация работает. Так что это была не проблема угловой анимации, а проблема CSS.
Надеюсь, это поможет кому-то еще.
Я думаю, что это будет работать:
import re
regexc = re.compile(r"(?:^|[^\\])'(([^\\']|\\'|\\\\)*)'")
def check(test, base, target):
match = regexc.search(base)
assert match is not None, test+": regex didn't match for "+base
assert match.group(1) == target, test+": "+target+" not found in "+base
print "test %s passed"%test
check("Empty","''","")
check("single escape1", r""" Example: 'Foo \' Bar' End. """,r"Foo \' Bar")
check("single escape2", r"""'\''""",r"\'")
check("double escape",r""" Example2: 'Foo \\' End. """,r"Foo \\")
check("First quote escaped",r"not matched\''a'","a")
check("First quote escaped beginning",r"\''a'","a")
Регулярное выражение r"(?:^|[^\\])'(([^\\']|\\'|\\\\)*)'"
вперед соответствует только вещам, которые мы хотим в строке:
Править:
Добавьте, что дополнительный regex в передней стороне для проверки на первую кавычку вышел.
Шаблон Douglas Leeder ((?:^|[^\\])'(([^\\']|\\'|\\\\)*)'
) не будет соответствовать "test 'test \x3F test' test"
и "test \\'test' test"
. (Строка, содержащая Escape кроме кавычки и обратной косой черты и строки, которой предшествует завершенная обратная косая черта.)
шаблон cletu ((?<!\\)'((?:\\'|[^'])*)(?<!\\)'
) не будет соответствовать "test 'test\\' test"
. (Строка, заканчивающаяся завершенной обратной косой чертой.)
Мое предложение по единственно заключенным в кавычки строкам - это:
(?<!\\)(?:\\\\)*'((?:\\.|[^\\'])*)'
Для обоих единственно заключенных в кавычки или дважды заключенных в кавычки жал Вы могли использовать это:
(?<!\\)(?:\\\\)*("|')((?:\\.|(?!\1)[^\\])*)\1
Тестовый прогон с помощью Python:
Doublas Leeder´s test cases:
"''" matched successfully: ""
" Example: 'Foo \' Bar' End. " matched successfully: "Foo \' Bar"
"'\''" matched successfully: "\'"
" Example2: 'Foo \\' End. " matched successfully: "Foo \\"
"not matched\''a'" matched successfully: "a"
"\''a'" matched successfully: "a"
cletus´ test cases:
"'testing 123'" matched successfully: "testing 123"
"'testing 123\\'" matched successfully: "testing 123\\"
"'testing 123" didn´t match, as exected.
"blah 'testing 123" didn´t match, as exected.
"blah 'testing 123'" matched successfully: "testing 123"
"blah 'testing 123' foo" matched successfully: "testing 123"
"this 'is a \' test'" matched successfully: "is a \' test"
"another \' test 'testing \' 123' \' blah" matched successfully: "testing \' 123"
MizardX´s test cases:
"test 'test \x3F test' test" matched successfully: "test \x3F test"
"test \\'test' test" matched successfully: "test"
"test 'test\\' test" matched successfully: "test\\"
Если я понимаю то, что Вы говорите (и я не уверен, что делаю), Вы хотите найти, что заключенная в кавычки строка в Вашей строке, игнорирующей, вышла из кавычек. Это правильно? Если так, попробуйте это:
/(?<!\\)'((?:\\'|[^'])*)(?<!\\)'/
В основном:
Хорошо, я протестировал это в Java (извините, это - больше моей фишки, чем Python, но принцип является тем же):
private final static String TESTS[] = {
"'testing 123'",
"'testing 123\\'",
"'testing 123",
"blah 'testing 123",
"blah 'testing 123'",
"blah 'testing 123' foo",
"this 'is a \\' test'",
"another \\' test 'testing \\' 123' \\' blah"
};
public static void main(String args[]) {
Pattern p = Pattern.compile("(?<!\\\\)'((?:\\\\'|[^'])*)(?<!\\\\)'");
for (String test : TESTS) {
Matcher m = p.matcher(test);
if (m.find()) {
System.out.printf("%s => %s%n", test, m.group(1));
} else {
System.out.printf("%s doesn't match%n", test);
}
}
}
результаты:
'testing 123' => testing 123
'testing 123\' doesn't match
'testing 123 doesn't match
blah 'testing 123 doesn't match
blah 'testing 123' => testing 123
blah 'testing 123' foo => testing 123
this 'is a \' test' => is a \' test
another \' test 'testing \' 123' \' blah => testing \' 123
который кажется корректным.
Используя выражение cletu с re.findall Python ():
re.findall(r"(?<!\\)'((?:\\'|[^'])*)(?<!\\)'", s)
Тест, находящий несколько соответствий в строке:
>>> re.findall(r"(?<!\\)'((?:\\'|[^'])*)(?<!\\)'",
r"\''foo bar gazonk' foo 'bar' gazonk 'foo \'bar\' gazonk' 'gazonk bar foo\'")
['foo bar gazonk', 'bar', "foo \\'bar\\' gazonk"]
>>>
Используя ТЕСТОВЫЙ массив строк cletu:
["%s => %s" % (s, re.findall(r"(?<!\\)'((?:\\'|[^'])*)(?<!\\)'", s)) for s in TESTS]
Работы как очарование. (Протестируйте его сами или честное слово.)