Thursday, October 10, 2019

Re: regexp : windows filename recognition

Am 10.10.2019 um 10:44 schrieb Ni Va:
> Don't understand why it returns 2 first chars on this example :
>
> + 20191009_191004_Vim.8.1.2125/ 4.0 KiB [D] 2019-10-
> echo substitute(getline(line('.')),'^..\zs\(.\+\)\(\s\+\d\+\.\d\+\)\@=.*$','\1', "") returns + 20191009_191004_Vim.8.1.2125/

The match starts after `\zs', what comes before is not substituted.

I wonder why the greedy \(.\+\) does not include any spaces.
Looks like \(\s\+\d\+\.\d\+\)\@= is checked before any backtracking takes place.
"no backtracking" => actually this depends on re=0 or re=2.

:echo substitute(getline('.'), '^..\(.\{-}\)\s\+\d\+\.\d\+.\{,20}$', '\1', '')

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5D9F4BEF.3030101%40yahoo.de.

No comments: