答案 0 :(得分:0)
我猜我们只想使用类似于以下的表达式捕获演示中列出的三个输入:
public function login(Request $request)
{
$validatedData = $request->validate([
'email' => 'required',
'password' => 'required'
]);
$email = $request->email;
$password = $request->password;
//If the user checked the remember me checkbox then make sure to remember him
if(isset($request->rememberMe)) {
if (\Auth::attempt(['email' => $email, 'password' => $password], true)) {
$user = User::findOrFail($email);
//Remember the user
\Auth::login($user, true);
return redirect('/home');
} else {
//Otherwise redirect back to login page with errors.
return redirect()->back()->withInput()->withErrors('Invalid email or password');
}
//If the user didn't check the remember me checkbox then don't remember him.
} else {
if (\Auth::attempt(['email' => $email, 'password' => $password])) {
$user = User::findOrFail($email);
\Auth::login($user);
return redirect('/home');
} else {
//Otherwise redirect back to login page with errors.
return redirect()->back()->withInput()->withErrors('Invalid email or password');
}
}
}
或
(\{.*?\}(.+?){.*?\})
答案 1 :(得分:0)
模式第一部分中的.*?
正在遍历输入的意外部分,直到找到为止,因为.
接受了所有这些字符。仅用?
来使量词变得懒惰是不够的-它会继续进行直到找到匹配项。
\{[^}]*?\}\s\{[^}]*?\}
答案 2 :(得分:0)
不确定我是否理解您的要求,我想您只希望成对的{}{}
匹配,并且在这两个之间只允许一个空格。您可以尝试使用此\{([^\{]+)\}\ \{([^\}]+)\}
。