I’ve seen \s++ but I’m not sure what it means. Could you please use an example? (\s means white space)
Share
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.
\s++means to match one or more whitespace characters possessively.It’s the same as writing
(?>\s+). The extra plus makes it possessive, like an independent subgroup.This illustrates the difference:
I’m counting how many steps the regex engine takes to solve the match. There isn’t a match though, but it doesn’t know that. It tries a bunch of real stupid things in the first case that the possessive match prevents it from trying in the second. Once a possessive match has been made, it cannot be backtracked into and recalculated.