bonjour,

j'utilise la fonction regex_search pour tester un string
le signe soustraction ("-") n'est pas pris en compte
pouvez-vous m'expliquer?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <regex>
#include <iostream>
#include <string>
 
int main()
{
    std::vector<std::string> vector_chaine = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "/", "*", "-", "+" };
    std::regex regex_definit( "[0123456789/*-+]" );    
    for(int i=0; i<vector_chaine.size(); i++)
    {
        //bool regex = std::regex_search( e.text.text , std::regex( "[0123456789/*-+]" ) );
        bool found = std::regex_search(vector_chaine[i], regex_definit);
        std::cout << "resultat recherche pour " << vector_chaine[i] << ": " << found << std::endl;
    }
 
    return (0);
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
resultat recherche pour 0: 1
resultat recherche pour 1: 1
resultat recherche pour 2: 1
resultat recherche pour 3: 1
resultat recherche pour 4: 1
resultat recherche pour 5: 1
resultat recherche pour 6: 1
resultat recherche pour 7: 1
resultat recherche pour 8: 1
resultat recherche pour 9: 1
resultat recherche pour /: 1
resultat recherche pour *: 1
resultat recherche pour -: 0
resultat recherche pour +: 1