为进行语法更正,请尝试找出我的段落在句子中是否包含1个或多个重复。
尝试类似的方法无济于事:
[A-Z][^\\.;]*(This was a)[^\\.;]*
例如,一个段落:
“这是一个炎热的夏天,似乎不是第一个。对于我的下一个假期,我计划去拉斯维加斯。这确实是一个奇怪的夏天。”
一个正则表达式可以发现我的段落在两个句子的开头包含1个或多个重复(“ This is a”)。什么是正确的正则表达式?
答案 0 :(得分:1)
这将告诉您至少重复一次。它不会告诉你它们在哪里:
FAIL tests/integration/login.test.js
/login
GET /
✓ should return the login form (300ms)
POST /
✕ should return 401 without incorrect user info (150ms)
✓ should return 403 without csrf token/header credentials (130ms)
✕ should return 200 with correct credentials (131ms)
● /login › POST / › should return 401 without incorrect user info
expect(received).toBe(expected) // Object.is equality
Expected: 401
Received: 403
61 | password = 'wrongpassword';
62 | const res = await postLogin();
> 63 | expect(res.status).toBe(401)
| ^
64 | });
65 |
66 | it('should return 403 without csrf token/header credentials', async () => {
at Object.toBe (tests/integration/login.test.js:63:26)
● /login › POST / › should return 200 with correct credentials
expect(received).toBe(expected) // Object.is equality
Expected: 200
Received: 403
77 | password = 'password';
78 | const res = await postLogin();
> 79 | expect(res.status).toBe(200)
| ^
80 | });
81 | });
82 | });
at Object.toBe (tests/integration/login.test.js:79:26)
(\b\S.*\b).*[.;:]\s+\K\1
-以以“单词”边界开头和结尾的非空格开头的事物的最长匹配项(\b\S.*\b)
-一切:).*
-“句子”终止符,后接至少一个空格[.:;]\s+
-比赛中不要包含任何内容\K
-括号中部分的重复内容