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]+ 

online demo

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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -