java - REGEX matching problem -


my entering string can in format tim0.vw0 ( starts tim or cnt or enc followed numbers, point , @ end char or chars digit @ end). how find out if entering string matches regex ?

something do:

import java.util.arrays;  public class test {     public static void main(string[] args) {          string regexp = "(tim|cnt|enc)\\d+\\.\\p{alpha}+\\d";          (string test : arrays.aslist("tim0.vw0",  "tim0.vw5", "tim0.0",                                          "tim99.a5",  "cnt0vw0",  "abc0.vw0",                                          "-tim0.vw0", "tim9.8x",  "enc0.55"))             system.out.printf("%-10s: %s%n", test, test.matches(regexp));     } } 

output:

tim0.vw0  : true tim0.vw5  : true tim0.0    : false tim99.a5  : true cnt0vw0   : false abc0.vw0  : false -tim0.vw0 : false tim9.8x   : false enc0.55   : false 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -