C ++正则表达式将不匹配空格

时间:2019-12-29 22:02:01

标签: c++ regex

请帮助..................................................... 我的正则表达式不适用于空格:

auth.token.phone_number

我也尝试过

    #include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
#include<cmath>

#include<sstream>
#include<fstream>
#include<list>
#include<numeric>
#include<map>
#include<iterator>

#include<regex>

using namespace std;

int main()
{

    regex date3{R"([A-Z][a-z]{2,}\s\d{1,})"};
    string s;
    cin>>s;
    smatch matches;
    if(regex_match(s,matches,date3)){
        cout<<matches[0];
    }
    return 0;
}

例如,我输入regex date3{R"([A-Z][a-z]{2,} \d{1,})"}; ,但它什么也不输出。

1 个答案:

答案 0 :(得分:2)

<?php include("php/config.php"); session_start(); // Create connection $conn = new mysqli($servername, $username, $password, $database); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $myusername = mysqli_real_escape_string($conn,$_POST['username']); $mypassword = mysqli_real_escape_string($conn,$_POST['password']); $sql = "SELECT id FROM kbt_users WHERE username = '$myusername' and passcode = '$mypassword'"; $result = mysqli_query($conn,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); $active = $row['active']; $count = mysqli_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count == 1) { session_register("myusername"); $_SESSION['login_user'] = $myusername; header("location: index.php"); }else { $error = "Your Login Name or Password is invalid"; } } ?> 在空白处分割输入,并丢弃这些空白。 相反,您可能要使用实例cin>>s