regex - Java Regexp pattern check -
pattern
^\\d{1}-\\d{10}|\\d{1,9}|^twc([0-9){12})$
should validate of these
1-23232445
1-232323
1-009121212
12
12222
twc12222
twc1222324
when test twc pattern doesn't match, have added "|" consider or condition , have numbers 0-9 limiting 12 digits. missing ?
twc([0-9)
i think might not working??
you need
twc([0-9]{12})
complete answer...
(\d{1}-\d{1,12})|^twc(\d{1,12})$
even nicer answer ..
^(\\d-|twc|)(\\d{1,12})$ // syntax believe match needs.
tested :)
^([0-9]-|twc|)([0-9]{1,12})$ // or ^(\d-|twc|)(\d{1,12})$
breakdown
^
this denotes start of string
\d or [0-9]
denotes 1 character of numbers 0 through 9 (note \d might not work in lanagues or require different syntax!)
|
is or
{1,12}
will accept particular pattern 1-12 times instance in code patternw ould \d or [0-9]
$
is end of line
this checks if line contains [0-9] - after,twc, or nothing space account nothing being there @ start reads 12 digits. should work cases.
testing
all unit tests. click on "java" if want see them :0
note:
you need @ syntax of using in cases might need \ things in order them work.. in c++/c 2 // in order these work please wary particular syntaxes.
Comments
Post a Comment