DosTips.com

A Forum all about DOS Batch
It is currently 29 May 2017 09:08

All times are UTC-06:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 31 Jan 2017 16:39 
Offline

Joined: 06 Nov 2016 13:15
Posts: 9
Hello,
I'm running a script to find some words, i. e. amor, man, pero, etc., but when I run it find this words even as part as other more long: amor=clamor, man=workman, pero=peronista, etc.
How can I find with findstr this words (amor, man, pero) but isolated, the bordering characters no matter (spaces, _, +, -, etc.), only I find the words isolated: the_man_tall (yes), the man_tall (yes), etc.; the_workman_fast (no), the+workman+fast (no), etc.
I use this command in my script:
Code: Select all
dir /b /s ^| findstr /i /g:keywords.txt

What I need to add?
Thanks!!!
Regards.


Top
   
PostPosted: 31 Jan 2017 17:28 
Offline
Expert

Joined: 12 Feb 2011 21:02
Posts: 1860
Location: United States (east coast)
You should do a regular expression search. FINDSTR has non-standard syntax for anchoring the beginning ( \< ) and end ( \> ) of a word.

keywords.txt
Code: Select all
\<amor\>
\<man\>
\<pero\>


Your existing FINDSTR command will probably work, but it never hurts to explicitly use the /R option for a regular expression search.
Code: Select all
dir /b /s ^| findstr /i /r /g:keywords.txt


Dave Benham


Top
   
PostPosted: 31 Jan 2017 19:08 
Offline

Joined: 06 Nov 2016 13:15
Posts: 9
Thanks Dave, your solution works!, but with a few words in keywords.txt. My keywords.txt is so big, and findstr in this mode take a eternity (or perhaps something is wrong).
Maybe the best is back to the old method, unless you or someone has a solution...
We see.
Thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Aacini, Bing [Bot], Compo, jeb, zimxavier and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited