Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Search for string in folder names
Newb Newb
1/29/2009 3:58:00 AM
Hi ...
I will be getting some string through params[:first_name].and i want to
get that
what are all the folders names contain that string.
For example
I have folders names like below
each one is folder name
1.kannan@angleritech.com~Vs~joy@angleritech.com
2.martin@angleritech.com~Vs~joy@angleritech.com
3.martin@angleritech.com~Vs~priya@angleritech.com
Now if i enter "joy" into that first name text box
i want to get all the folders which has joy in the folder names
for the above example i will have to get the below results for the
folder search because it contains joy in the folder name
kannan@angleritech.com~Vs~joy@angleritech.com
martin@angleritech.com~Vs~joy@angleritech.com
pls help me up how can i implemend this.
Thanks in advance
Cheers
--
Posted via
http://www.ruby-...
.
2 Answers
Andrew Timberlake
1/29/2009 4:03:00 AM
0
[Note: parts of this message were removed to make it a legal post.]
On Thu, Jan 29, 2009 at 5:58 AM, Newb Newb <revathy.p@angleritech.com>wrote:
> Hi ...
> I will be getting some string through params[:first_name].and i want to
> get that
> what are all the folders names contain that string.
> For example
> I have folders names like below
> each one is folder name
>
>
> 1.kannan@angleritech.com~Vs~joy@angleritech.com
> 2.martin@angleritech.com~Vs~joy@angleritech.com
> 3.martin@angleritech.com~Vs~priya@angleritech.com
>
>
> Now if i enter "joy" into that first name text box
> i want to get all the folders which has joy in the folder names
> for the above example i will have to get the below results for the
> folder search because it contains joy in the folder name
>
> kannan@angleritech.com~Vs~joy@angleritech.com
> martin@angleritech.com~Vs~joy@angleritech.com
>
>
> pls help me up how can i implemend this.
> Thanks in advance
>
>
> Cheers
> --
> Posted via
http://www.ruby-...
.
>
>
Dir.glob("/path/to/base/dir/*#{search_string}*")
Think carefully about the security of working with input directly from user
input on the file system.
--
Andrew Timberlake
http://ramblingso...
http://www.linkedin.com/in/andrew...
"I have never let my schooling interfere with my education" - Mark Twain
Jayce Meade
1/29/2009 4:07:00 AM
0
I am no expert in this, just my two cents,but I would do the following:
def getNames(param, directory = Dir.getwd)
foldernames, matches = Dir.entries(directory), []
foldernames.each { |fn|
if fn.include?(param) then matches.push(fn) end
}
puts matches.join("\n")
end
I'm not an expert as I've said, but for just creating a list of folders that
match your parameters, such as joy, I think that would retrieve an array of
strings for filenames that include the string passed for 'param' in the
directory passed to 'directory' or the current directory if one is not
specified...
Doesn't solve your text box part, but I'd try something along the lines of
what I put above to retrieve the filenames. Hope that helps you. :)
- Jayce
--------------------------------------------------
From: "Newb Newb" <revathy.p@angleritech.com>
Sent: Wednesday, January 28, 2009 7:58 PM
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Search for string in folder names
> Hi ...
> I will be getting some string through params[:first_name].and i want to
> get that
> what are all the folders names contain that string.
> For example
> I have folders names like below
> each one is folder name
>
>
> 1.kannan@angleritech.com~Vs~joy@angleritech.com
> 2.martin@angleritech.com~Vs~joy@angleritech.com
> 3.martin@angleritech.com~Vs~priya@angleritech.com
>
>
> Now if i enter "joy" into that first name text box
> i want to get all the folders which has joy in the folder names
> for the above example i will have to get the below results for the
> folder search because it contains joy in the folder name
>
> kannan@angleritech.com~Vs~joy@angleritech.com
> martin@angleritech.com~Vs~joy@angleritech.com
>
>
> pls help me up how can i implemend this.
> Thanks in advance
>
>
> Cheers
> --
> Posted via
http://www.ruby-...
.
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Search for string in folder names
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password