matlab - Splitting a string into various bits -


I have a string that looks like this:

substring = 'Xmole (1) = 0.0xmole (2) = 1.0 arho (1) = 2343rho (2) = 2343 '

I need to split it into:

  Xmole (1) = 0.0 Xmole (2) = 1.0 rho (1) = 2343 rho (2) = 2343   

Is this an easy way to do this

If your number is always in the form of your example, that is, the number and possibly a decimal point (and for example "1.0e-3") Not in):

  ind = regexp ( Pastring, '= [\ d.] +', 'End'); Results = MAT 2SL (Substring, 1, [IND (1) Difference (Ind)]). ';   

variable result Each cell has a cell array with one string:

  result = 'xmole (1) = 0.0 '' Xmole (2) = 1.0 '' rho (1) = 2343 '' rho (2) = 2343 '   

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -