'Regular Expression' VS 'String Comparison operators / functions'

lorimi

New Member
This question is designed around the performance within PHP but you may broaden it to any language if you wish to.After many years of using PHP and having to compare strings I've learned that using string comparison operators over regular expressions is beneficial when it comes to performance.I fully understand that some operations have to be done with Regular Expressions down to there complexity but for operations that can be resolved via regex AND string functions.take this example:PHP\[code\]preg_match('/^[a-z]*$/','thisisallalpha');\[/code\]C#\[code\]new Regex("^[a-z]*$").IsMatch('thisisallalpha');\[/code\]can easily be done withPHP\[code\]ctype_alpha('thisisallalpha');\[/code\]C#\[code\]VFPToolkit.Strings.IsAlpha('thisisallalpha');\[/code\]There are many other examples but you should get the point I'm trying to make.What version of string comparison should you try and lean towards and why?
 
Back
Top