How to use regular expression and assign result into valuables in Android??

Posted by user304078 on Stack Overflow See other posts from Stack Overflow or by user304078
Published on 2010-05-21T02:14:14Z Indexed on 2010/05/21 2:20 UTC
Read the original article Hit count: 233

Filed under:
|
|

Dear all,

I have to say sorry for my poor English first...

I have a string named s_Result which will be parsed from Internet, the format may be "Distance: 2.8km (about 9 mins)", and there are 4 variables which are f_Distance, m_DistanceUnit, f_timeEst, m_timeEstUnit.
My question is, how to parse s_Result and assign 2.8, km, 9, mins into f_Distance, m_distanceUnit, f_timeEst, and m_timeEstUnit respectively using regular expression??

I tried using "\d+(.\d+)?" in RegEx Tester and the result showed 2 matches found, but if use "\\d+(\\.\\d+)?" in Android code, it showed nothing matched!!!

Is there any suggestion??
Thanks for your help!!

© Stack Overflow or respective owner

Related posts about java

Related posts about regex