RegEx Help

Hello!

I need help with a php form for social security number in Sweden.

The visitors will type in these formats:
810102-4584
8101024584
198101024584
810102-4584

I would always like to save it as 810102-4584. The numbers may vary it is always a - between the numbers.

Thank you.
Best regards from Sweden

What have you tried?

@SwedishProgrammer

There’s a website that has a lot of pre-defined RegEX Patterns. The link below might be of some help to you.

http://regexlib.com/UserPatterns.aspx?authorid=8d494c1e-5175-4420-8797-75851a9dfac1&AspxAutoDetectCookieSupport=1

If you’re trying to learn RegEX and want to know what the patterns do…

Here’s a good site for you, you can paste the regex in it and it will explain what the regex is looking for and how it works.

https://regex101.com/

If you’re still having issues, implementing it. Post your code for us to take a look at.

Sponsor our Newsletter | Privacy Policy | Terms of Service