How bad is my regex?

lorettaworm

New Member
Ok so I managed to solve a problem at work with regex, but the solution is a bit of a monster.The string to be validated must be: zero or more: \[code\]A-Z a-z 0-9\[/code\], spaces, or these symbols: \[code\]. - = + ' , : ( ) /\[/code\]But, the first and/or last characters must not be a forward slash \[code\]/\[/code\]This was my solution (used \[code\]preg_match\[/code\] php function):\[code\]"/^[a-z\d\s\.\-=\+\',:\(\)][a-z\d\s\.\-=\+\',\/:\(\)]*[a-z\d\s\.\-=\+\',:\(\)]$|^[a-z\d\s\.\-=\+\',:\(\)]$/i"\[/code\]A colleague thinks this is too big and complicated. Well it works, so is it really that bad? Anyone in the mood for some regex-golf?
 
Back
Top