regexp : windows filename recognition

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

regexp : windows filename recognition

Ni Va
Hi,

Here is a kind of filename in fat chars that I would like to recognize:

  $FOOBBBAR_Foooofbar_f_oobar_(2019-07-29) - Copie.zed.lnk                                                  232.0 KiB     2019

Thank you

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/e94f889a-e44e-4381-a960-6bb99131c7c1%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

arocker
> Here is a kind of filename in fat chars that I would like to recognize:
>
>  * $FOOBBBAR_Foooofbar_f_oobar_(2019-07-29) - Copie.zed.lnk*
>                                   232.0 KiB     2019

There's a practically infinite universe of expressions that could be made
to match it. What's distinctive about it?

It might help if you could provide an example of something that you don't
want to match, and point out what discriminates the match vs non-match.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4d6886909e5cbcdf5c26478f0cbc1fb6.squirrel%40webmail.vybenetworks.com.
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

Ni Va
Anything chars contained in windows'filename before a lot of spaces and begining on third char after start of line.

Anything chars of filename= \w\s-_. many times

^..filename                                    some others chars.*$

Thank you

Le mercredi 9 octobre 2019 14:09:25 UTC+2, [hidden email] a écrit :
> Here is a kind of filename in fat chars that I would like to recognize:
>
>  * $FOOBBBAR_Foooofbar_f_oobar_(2019-07-29) - Copie.zed.lnk*
>                                   232.0 KiB     2019

There's a practically infinite universe of expressions that could be made
to match it. What's distinctive about it?

It might help if you could provide an example of something that you don't
want to match, and point out what discriminates the match vs non-match.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/01252a18-de2d-4392-9391-e20376274aa8%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

Andy Wokula
Am 09.10.2019 um 14:16 schrieb Ni Va:
> Anything chars contained in windows'filename before a lot of spaces
> and begining on third char after start of line.
>
> Anything chars of filename= \w\s-_. many times
>
> ^..filename                                    some others chars.*$

     /^..\zs.\+$

List of false positives:
     XXX

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5D9E087E.7030005%40yahoo.de.
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

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/

Thank you for help.
NiVa

Le mercredi 9 octobre 2019 18:19:24 UTC+2, Andy Wokula a écrit :
Am 09.10.2019 um 14:16 schrieb Ni Va:
> Anything chars contained in windows'filename before a lot of spaces
> and begining on third char after start of line.
>
> Anything chars of filename= \w\s-_. many times
>
> ^..filename                                    some others chars.*$

     /^..\zs.\+$

List of false positives:
     XXX

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/68b5a53f-5d7d-4ae4-b733-fe58a125847f%40googlegroups.com.

examples.txt (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

Andy Wokula
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5D9F4BEF.3030101%40yahoo.de.
Reply | Threaded
Open this post in threaded view
|

Re: regexp : windows filename recognition

Ni Va


It works well with .*$ in order to substitute and get first backward reference.
^..\(.\{-}\)\s\+\d\+\.\d\+.\{,20} needed to add .*$


Thank you.


Le jeudi 10 octobre 2019 17:19:25 UTC+2, Andy Wokula a écrit :
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/e9d96fcc-6fd9-4072-9601-15ed01eb0c99%40googlegroups.com.

Sans titre.png (76K) Download Attachment