I’m banging my head to the table in trying to write a regular expression that filter out strings that contain only Swedish letters, hyphens and single whitespaces – that is, not two in a row. I’ve got this preg_match('/^[A-ZÅÄÖa-zåäö-]+\s{1}$/',$b) and I feel like I’ve tried a hundred different models, but it’s not working. How would I accomplish this?
I’m banging my head to the table in trying to write a regular expression
Share
Often the best way to solve a problem like this is splitting it into two separate regular expression checks.
Try: