java - Regex to match only one character sequence within string -


i have string in jlist looking split regex (for future simplicity if requirements change)

the string looks lot this:

id: gf68464, name: productname

the id combination of letters , numbers , length.

i want id matched, i.e excluding "id: " , after comma following id.

here have far doesn't seem ask to

[^id: ][a-za-z1-9][^,^.] 

further info (edit)

i plan on extracting id match against array. (hence need regex). done different way?

you can try this:

id:\s*(\w+), 

and extract 1st capturing group. can use lookarounds (+1 @p.s.w.g).


string str = "id: gf68464, name: productname";  matcher m = pattern.compile("id:\\s*(\\w+),").matcher(str); if (m.find()) {     system.out.println(m.group(1)); } 
 gf68464 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -