Source language: Translate to:

Search for string in file

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Search for string in file

Postby Wrangler » Thu Dec 06, 2012 4:24 pm

I'm looking for a plugin that will search for an EXACT MATCH and/or CASE SENSITIVE to a string in a file and return the line number. hpwlinenumber handles the case sensitive, but I can't find one that will do both.

Anyone know of one?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Search for string in file

Postby Tony Kroos » Thu Dec 06, 2012 6:51 pm

FIND [/V or /C][/I][/N] "string" [drive:][path]filename
where:
/V Displays all lines not containing the string specified.
/C Displays the count of lines containing the string.
/I Ignores the case of characters when searching for the string.
/N Displays the line numbers with the displayed lines.

"string" Specifies the text string to find.
drive:\path Specifies the location of the file or files to search.
filename Specifies the name of the file to be searched.

p.s: some magic to copy cpnsole output directly to clipboard...
Run "cmd.exe" "/c find /n [#34]String[#34] [#34]c:\file.txt[#34] | clip" "Wait+Hidden" "" ""
... and "plugin" is ready.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: Search for string in file

Postby HPW » Thu Dec 06, 2012 11:06 pm

Hello,

To understand the problem: What does hpwlinenumber not?

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Search for string in file

Postby Wrangler » Fri Dec 07, 2012 9:08 am

Hi Hans-Peter,

hpwlinenumber doesn't have an option for an EXACT MATCH. For example, if the file contains strings, one per line, and one of the strings is 'mywebsite 1'. I want it to find ONLY 'mywebsite 1' and NOT 'mywebsite'. In other words search for the entire string in the line. The case sensitive option works well. Is it possible for you to add this option?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Search for string in file

Postby HPW » Fri Dec 07, 2012 12:36 pm

Hm,

I would have thought that when you search for 'mywebsite 1' that it would only find the exact match.
I have to look into the source and to test myself.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Search for string in file

Postby Wrangler » Fri Dec 07, 2012 12:38 pm

Thanks, Hans-Peter!
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Search for string in file

Postby HPW » Fri Dec 07, 2012 1:34 pm

I added 'mywebsite' to line 11 of my Fruitlst.txt sample file and 'mywebsite 1' to line 22.
When I use hpwLineNumber on variable or file I get 11 when I search for 'mywebsite' and 22 when I search for 'mywebsite 1'.
Just as I would expect. In fact it only supports the exact match (besides the case feature). What do you different?

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Search for string in file

Postby Wrangler » Fri Dec 07, 2012 2:03 pm

Thanks for checking. The problem seems to come when the string has 3 words or more. First I added 'web site 1' to file. Now I want to add a string 'web'. I want to make sure that the string 'web' is not contained on any line in file so I search for it. The plug returns the line number 'web site 1' is located.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: Search for string in file

Postby HPW » Fri Dec 07, 2012 2:48 pm

I do not get the logik.
When you search for web the return of the line number of web site 1 is correct, since the line contains the word.
That the way hpwLineNumber was designed.
You seems to want only the line which has only the one word.

You may use this for that:

Code: Select all
hpwLineNumber "[FruitLst1]" "[NumberStr][#13]" "True" "[LNumb]"


Note the [#13] behind the variable.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Search for string in file

Postby Wrangler » Fri Dec 07, 2012 2:53 pm

That's got it! And it still works for strings with more than one word. :)

Thanks much for your help, Hans-Peter.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 2 guests