java - Splitting and Parsing formula String -
i have below formula
(trig01:bao)/(((trig01:count*86400)-trig01:upi-trig01:sos)*2000)
i want split , output of staring values before colon only,
final output need -
{ "bao","count","upi","sos" }
thanks in advance,
you can try positive lookbehind in below regex pattern alphanumeric character after colon
(?<=:)[^\w]+
pattern explanation:
(?<= behind see if there is: : ':' ) end of look-behind [^\w]+ character except: non-word characters (all a-z, a-z, 0-9, _) (1 or more times)
sample code:
string str="(trig01:bao)/(((trig01:count*86400)-trig01:upi-trig01:sos)*2000)"; pattern p=pattern.compile("(?<=:)[^\\w]+"); matcher m=p.matcher(str); while(m.find()){ system.out.println(m.group()); }
Comments
Post a Comment