[Tutor] doubt in Regular expressions

Luke Paireepinart rabidpoobear at gmail.com
Sun Jun 25 23:26:26 CEST 2006


Post Script:  Sorry for the double e-mail, Evans.  I forgot to forward 
it to the list the first time.
Also, why don't replies automatically forward themselves to the list 
like the pygame mailing list does?
For privacy reasons, in case you want to reply to someone separately?
End of P.S.
---------------------

Evans Anyokwu wrote:
> bump
Please don't send useless messages like this to the list.  If you don't 
get a reply you want in a few days, send the message again.
You waited 30 minutes and bumped the post.  This is a huge turn-off for 
me and makes me not even want to consider your problem.
However, I'll assume that you're used to asking questions on 
high-traffic message boards where this type of thing is necessary.

[snip header]
>
>     hello all,
>       i want to search strings in the database available and return
>     the link of the string instead  simply returning the words...  by
>     using regular expressions(RE) i got a way to perform the  string
>     matches....give some info regarding how to return the link of the
>     matched strings...
>      ravi.
>
Again, you need to be more specific.  We have no idea what your data 
structure looks like so we have no idea how to help you.
This is the way I would do it.

class SearchObj(object):
   def __init__(self):
      self.database = {}
   def addElement(astr,alink):
      self.database[astr] = alink
   def searchElement(astr):
      bstr = "blah blah" #insert code to match the element they're 
trying to search for with the closest one in the database.
      try:  return self.database[bstr]
      except:  pass

This sounds like what you're trying to do, but I don't think it's a very 
good way to make a search engine.
no matter how your string-matching is, a single keyword shouldn't be 
mapped to a single site link.  That doesn't make sense!
so if someone searches for "Puppy" they'll only get a single link back?
What's the point of that?
I want to search through the sites not have you search through them for 
me, find out which you think I want, and only give me the link to that one.
If I did I would use Google's I'm Feeling Lucky.
For that matter, I would use Google for any search.
Why are you wanting to make this search engine?
If it's for practice, I feel that it's not a very good project to 
practice on, because the design issues are so much larger than the 
programming itself.
For practicing programming you should probably use some simple example 
that requires a lot of code.  Like Tetris or Pong.
If you're doing this for commercial use, you should just look into 
adding a Google SiteSearch to your page.
python.org did this and it works fantastically.
If you insist on continuing in this, I wish you luck and I hope 
everything turns out how you want it.
Are you going to send us a link to it when you're done?
-Luke


More information about the Tutor mailing list