regex - Check if term preceeding keyword is a number -


given string:

3 design features

, i'm trying check if term preceeding "design features" number or not using below. (the number can exist 2 or 2.)

score=0; str = <p>3 design features</p> regexp_number =  "/^[0-9]+./"; if(str_detect(y,regexp_number) ==true)  {    score=score++;    } 

this returns 0. doing wrong here? hoping can point out?

thanks in advance. -simak

your regex wrong. says must contain . match, rather optionally contain 0 or 1 .. change

regexp_number =  "/^[0-9]+.?/"; 

Comments