For a personal project I am trying to write a wee page which includes needing to validate text against a regular expression.... I want to only allow a-z and 0-9 but exclude â etc. At the moment I have: ^[a-zA-Z0-9]\w{1,30}$ Code (Regular Expression): This works for most things but not accented letters.... any ideas what I need to add to exclude these?
You don't want it to allow accented letters? Why even do the \w part then? Try just running it against "^[a-zA-Z0-9]{1,30}$"
Because whilst I conn myself into thinking I can do programming things like regex I know I dont know much about so would normally let my developers do but weekend + personal project means that I am reliant on websites
This pattern will work when multibyte support is enabled. #^[a-z0-9]{1,30}$#i Code (markup): When you run phpinfo(), do you have an mbstring section ? If you do, what's listed for the options in that section ? Does it mention anything about Multibyte regex (oniguruma) version ?
Sorry about that, thought I was still in the PHP section. The "Set the correct character set" section in this MSDN article looks promising.
No problem, made the same mistake myself the other day by posting a .Net solution in the PHP section.... was interesting to see the 6 lines or so in .Net took 30+ in PHP to do the same thing though.