i trying create regex match 1 string format. strings this
a3476,texta b5628,textb a9871,textc
the first character should either 'a' or 'b' , follow integer number should 4 chars in length , followed ','. after comma 3 words repeate either 'texta' or 'textb' or 'textb'.
i have tried regex
(a|b)(\d{4})(,)(texta|textb|textc)
when add alphabet in integer number or integer number greater 4 chars in length string match should fail not failing.
suppose if string this
a653k7876,texta
i getting result 7876,texta
. result missing character 'a' , reading integer end. intention should fail.
your regex fine, except should indicate should start , end match. ^
special character indicates start of line or string, , $
end. so, try instead:
^(a|b)(\d{4})(,)(texta|textb|textc)$
make sure specify regexoptions.multiline
when creating regex
object make work.
Comments
Post a Comment