I am trying to create a PHP REGEX that will match if two words appear next to each other with ANY number of spaces between them.
For example, match "Daniel Baylis" (3 spaces between 'Daniel' and 'Baylis'). I tried with this but it doesn't seem to work:
"/DANIEL[ ]{1,5}BAYLIS/" (this was to check up to 5 spaces which the most I expect in the data)
and
"/DANIEL[ ]{*}BAYLIS/"
I need to extract names from within larger bodies of text and names can appear anywhere within that text. User input error is what creates the multiple spaces.
Thanks all! - Dan
DANIEL[ ]{1,5}BAYLIS
this looks good, why didn't work? – Kentgrep -i
, it worked. what i tried was ` echo "Daniel BAYLIS"|grep -iP "Daniel[ ]{1,5}Baylis"` – Kent