vim - Matching a number from a table in regex -


don't mind weird encoding.

is there way (in table this, starts of damage stability) , ends "flooding percentage" line, match numbers last column less value (say, 0.018)?

i'm practicing regular expressions, way me @ stage. hoping @ least recommend best way go it.

                    summary of results of damage stability                        ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ        damage case               %  r  heel   gm     fbmin   gz>0  gzmax  area                                         (deg)   (m)     (m)   (deg)   (m)  (m.rad)  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ  109.10s                        100 1  -4.1   0.438   1.243  59.2  0.133  0.021                                   20 1  -6.6   0.740   2.215  63.4  0.479  0.049                                   40 1  -5.8   0.721   2.372  64.2  0.393  0.045                                   60 1  -3.2   0.728   2.537  66.8  0.277  0.041                                   80 1  -0.8   0.721   2.354  66.8  0.192  0.037    109.10p                        100 1  -4.1   0.438   1.243  59.2  0.133  0.021                                   20 1   4.5   0.688   2.494  65.5  0.507  0.049                                   40 1   3.7   0.684   2.580  66.3  0.417  0.046                                   60 1   1.1   0.720   2.599  68.9  0.300  0.043                                   80 1  -1.2   0.693   2.350  65.2  0.177  0.035     110.10s                        100 1  -3.0   0.748   1.837  39.7  0.494  0.049                                   20 1  -2.9   0.777   2.333  43.1  0.594  0.052                                   40 1  -2.9   0.777   2.333  42.5  0.576  0.052                                   60 1  -2.9   0.756   2.294  41.6  0.551  0.050                                   80 1  -2.9   0.748   2.077  40.7  0.520  0.049    110.10p                        100 1  -0.5   0.733   2.143  41.6  0.484  0.047                                   20 1  -0.5   0.763   2.627  45.3  0.613  0.051                                   40 1  -0.5   0.763   2.627  44.7  0.592  0.051                                   60 1  -0.5   0.740   2.593  43.8  0.558  0.049                                   80 1  -0.5   0.767   2.372  42.7  0.516  0.048     %     : flooding percentage.                                                     r     : r=1 if run-off weights considered, r=0 if no run-off.                    heel  : heel @ equilibrium (negative if equilibrium on port).                gm    : gm @ equilibrium.                                                       fbmin : minimum distance of margin line, weathertight or non-weathertight                points waterline.                                                   gz>0  : range of positive gz limited immersion of non-weathertight openings.  gzmax : maximum gz value.                               

the 0.018 example not good, since numbers in last column greater 0.018.... took minutes find out. thought vim substitution command has problem...

looking @ example, given range border (starts of damage stability , ends "flooding percentage") not necessary, know requirement best. added range in command too.

in command below, changed 0.040 see difference. below command add * @ end of matched number.

 /stability/,/flooding/s/\v([0-9.-]+)\s*$/\=str2float(submatch(1))<0.040? submatch(1).'*':submatch(1) 

short explanation:

 /stability/,/flooding/                                      " fit range, defined  s/                                                          " start substitution  \v                                                          " use magic, save escaping  ([0-9.-]+)\s*$/                                             " match last number column (float or negative)  \=str2float(submatch(1))<0.040? submatch(1).'*':submatch(1) " vimscript expression, if value<0.040, add '*' 

if on linux box, job easy done awk. if microsoft person, excel maybe (i not sure) tool.

edit

from comments, think didn't meant. i

the command:

 /stability/,/flooding/s/\v([0-9.-]+\d)\s*$/\=str2float(submatch(1))<0.040? submatch(1).'<':submatch(1)/ 

then search:

/[0-9.-]\+\d\ze<$ 

note highlighted numbers (i still use 0.040 see difference), add flag/suffix <. move next highlighted number pressing n. previous n. if finish "reading" file, quit :q! or zq skip changes.

i hope meets requirement.

see example: enter image description here


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -