regex - How to find {min,max} repeats regular expression patterns in Visual Studio or SSMS "Find and Replace"? -
i knew have in regular expression syntax world.
*the syntax {min,max}, min positive integer number indicating minimum number of matches, , max integer equal or greater min indicating maximum number of matches.
so {0,} same , , {1,} same +
http://www.regular-expressions.info/repeat.html
but how can use in sql server management studio or visual studio "find , replace" window. find related microsoft syntax in msdn. like:
[0-9]^4 matches 4-digit sequence.
the visual studio regex implementation (in versions until vs 2010) nonstandard 1 least, , doesn't have feature. can spell out:
*
or @
: match 0 or more of preceding expression
+
or #
: match 1 or more of preceding expression
^n
: match n repetitions of preceding expression
so a{2,4}
you'd have use a^4|a^3|a^2
(see polygenelubricant's comment explanation why need in descending order).
more recent versions of vs support entire set of .net regexes.
Comments
Post a Comment