.net - Regex for a string of n characters -


i want use .net's regex.ismatch function determine if string 8 characters long , matches expression ak-\d\d\d\d[ff]. so, ak-9442f match not ak-9442f2 nor ak-9442. how construct expression?

using static regex.ismatch, can do:

if (regex.ismatch(myteststring, @"^ak-\d{4}[ff]$")) {   // passed } 

should work purpose. broken down, it's:

^       # must match beginning of string   ak-     # string literal, "ak-"   \d{4}   # \d digit, {4} means must repeated 4 times   [ff]    # either upper or lowercase f $       # must match end of string 

gskinner test


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -