Other than perhaps enhanced readability for very simple patterns, why would someone choose to use the Like operator in VB.NET over regular expressions for string pattern matching? Are there any advantages?
相关问题
- 'System.Threading.ThreadAbortException' in
- how to use special characters like '<'
- Improve converting string to readable urls
- Regex to match charset
- Regex subsequence matching
相关文章
- vb.net 关于xps文件操作问题
- Optimization techniques for backtracking regex imp
- Regex to check for new line
- Checking for DBNull throws a StrongTypingException
- Allow only 2 decimal points entry to a textbox usi
- Using the typical get set properties in C#… with p
- Comparing speed of non-matching regexp
- Regular expression to get URL in string swift with
Probably. If you want to take a look at how Like is implemented, much (all?) of it is in
Microsoft.VisualBasic.CompilerServices.LikeOperator
, and the rudiments can be seen in#LikeObject
and#LikeString
. Looking at the documentation,Like
obviously uses a pretty strict subset of the full-on regular expression engine, and like just about any Perl-Compatible Regular Expression engine, there's some heavy lifting that may be overkill for simple expressions.That said, in my opinion, it comes down to style. If you feel that
If (myString Like "a?bb")
is more readable, idiomatic, and consistent with the rest of your code, go for it. It would appear to me that going either way for anything but the aforementioned reasons is microoptimization theatre, especially since you can compile regexes if you need to.