java - check for a substring in a string before the first comma -
i have set of strings separated ,
example:
abc,defg,ijkl pqrs,tu,vv ,klmnop,qwe aamn,nn,khhk
as can see, third line doesn't start substring. starts comma.
using regex how can tell string starts substring of random length before first comma.
description
^"[^"]+",
this regular expression following:
- verifies string starts substring
- requires substring random length greater zero
example
live demo
https://regex101.com/r/ke3bg5/1
sample text
abc,defg,ijkl pqrs,tu,vv ,klmnop,qwe aamn,nn,khhk
sample matches
abc, pqrs, aamn,
explanation
node explanation ---------------------------------------------------------------------- ^ beginning of "line" ---------------------------------------------------------------------- [^,]+ character except: ',' (1 or more times (matching amount possible)) ---------------------------------------------------------------------- , ',' ----------------------------------------------------------------------
Comments
Post a Comment