Doubt with regular expression in Node JS

1
          //Para traer el Id del estudiante , este me funciona perfectamente
            var idPatt ="[0-9]+";
            var patt = new RegExp("/estudiante/id/"+ idPatt);

            //Para traer el nombre del estudiante
            //Creo que acá estoy definiendo mal esto, la verdad no se como 

            var nombre="[A-Za-z]+";
            urlpornombre =new RegExp("/estudiante/name/"+ nombre);



            if(patt.test(req.url)){
                patt = new RegExp(idPatt);
                var id = patt.exec(req.url);
                st.getId(req, resp,id);

            }else if(urlpornombre.test(req.url)){
                urlpornombre = new RegExp(nombre);
                var name = urlpornombre.exec(req.url);
                st.getName(req, resp,name);

            }           
            else{
                httpMsgs.show404(req,resp);
            }

When I bring the student's id it brings me very well, but when I try to bring the student's name it bursts, I think the problem is due to the regular expression I'm using since I do not know how to do it. that I receive both upper and lower strings, which for example at the time I say: localhost: 3000 / student / name / Juan, show me all the students who start with Juan.

    
asked by jmtaborda 04.05.2018 в 21:03
source

0 answers