I would like to accept any spaces with [\s] between to words, but not returns on the line -> [^\n].
I’m using
([\w\-]+)([\s[^\n]])([\w\-]+)
but i doesn’t work.
How can I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A character class within another character class will not work. It would be better to specify what you want to match. So
[ \t]+which meansone or more spaces or tabs.Two more points:
1.
-does not need to be escaped in a character class if it is the first or the last character, so[\w-]or[-\w]will work fine.2. Unless you want to use the white space characters between the words you do not need to use brackets.
In summary, the following should work fine:
([-\w]+)[ \t]+([-\w]+)