• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(11927)  |  Call(11836)  |  Derive(0)  |  Import(91)
Scan through string looking for a match to the pattern, returning
a match object, or None if no match was found.

        def search(pattern, string, flags=0):
    """Scan through string looking for a match to the pattern, returning
    a match object, or None if no match was found."""
    return _compile(pattern, flags).search(string)
        


src/g/o/google-app-engine-HEAD/lib/webob/docs/wiki-example-code/example.py   google-app-engine(Download)
            basename = re.sub(r'[_-]', ' ', basename)
            return basename.capitalize()
        content = self.full_content
        match = re.search(r'<title>(.*?)</title>', content, re.I|re.S)
        return match.group(1)
 
    @property
    def content(self):
        if not self.exists:
            return ''
        content = self.full_content
        match = re.search(r'<body[^>]*>(.*?)</body>', content, re.I|re.S)
        return match.group(1)
 

src/o/b/objectlistview-HEAD/python/trunk/Examples/SqlExample.py   objectlistview(Download)
    def CalculatePrimaryKey(self, stmt):
        """
        Figure out the primary key of the table involved in the given statement.
        """
        # Can we find the name of the table involved?
        match = re.search(r"from\s+(\b[a-z0-9$@_]+\b)", stmt, flags=re.IGNORECASE)
        if not match:

src/g/o/google_appengine-HEAD/lib/webob/docs/wiki-example-code/example.py   google_appengine(Download)
            basename = re.sub(r'[_-]', ' ', basename)
            return basename.capitalize()
        content = self.full_content
        match = re.search(r'<title>(.*?)</title>', content, re.I|re.S)
        return match.group(1)
 
    @property
    def content(self):
        if not self.exists:
            return ''
        content = self.full_content
        match = re.search(r'<body[^>]*>(.*?)</body>', content, re.I|re.S)
        return match.group(1)
 

src/g/a/gaesdk-python-HEAD/lib/webob/docs/wiki-example-code/example.py   gaesdk-python(Download)
            basename = re.sub(r'[_-]', ' ', basename)
            return basename.capitalize()
        content = self.full_content
        match = re.search(r'<title>(.*?)</title>', content, re.I|re.S)
        return match.group(1)
 
    @property
    def content(self):
        if not self.exists:
            return ''
        content = self.full_content
        match = re.search(r'<body[^>]*>(.*?)</body>', content, re.I|re.S)
        return match.group(1)
 

src/s/h/shedskin-HEAD/examples/mm/mastermind.py   shedskin(Download)
    def __parseColour(self,s):
        if (re.search("^r",s) is not None):
            return peg.Peg(colour.Colours.red)
        elif (re.search("^p",s) is not None):
            return peg.Peg(colour.Colours.purple)
        elif (re.search("^g",s) is not None):
            return peg.Peg(colour.Colours.green)
        elif (re.search("^y",s) is not None):
            return peg.Peg(colour.Colours.yellow)
        elif (re.search("^w",s) is not None):
            return peg.Peg(colour.Colours.white)
        elif (re.search("^b",s) is not None):

src/l/a/Langtangen-HEAD/src/py/examples/q4w/q4w-generate.py   Langtangen(Download)
    print 'Just make a .q4w file with questions and answers in a directory;'
    print 'q4w-generate.py will copy the necessary files for you.'
    sys.exit(1)
if not re.search(r'\.q4w$', q4wfilename):  # .q4w suffix?
    print 'Input file', q4wfilename, 'must end with .q4w'
    sys.exit(1)
else:
 
question_counter = 0
for line in lines:
    if re.search(r'^\s*\#.*', line):      # comment line?
        line = string.strip(line)
        # write line except opening '#' ('\n' is already
        # stripped by string.strip),  inside HTML comment signs:
        htmlfile.write('<!-- ' + line[1:] + ' -->\n')
        last_tag = '#'
        #print 'DEBUG: found a comment:',line[1:-1]
#   elif re.search(r'^(Q|A|T|):', line):  # Q: or A: or T:  ?
    elif re.search(r'^((Q|A|T|):|\|)', line):  # Q: or A: or T: or | ?
        title_line = re.search(r'^T:(.*)', line)
            htmlfile.write('<IMG SRC="colorline.gif">\n</CENTER>\n')
            last_tag = 'T'
 
        question_line = re.search(r'^Q:(.*)', line)
        if question_line:
            question_counter = question_counter + 1
            question = string.strip(question_line.group(1))
            htmlfile.write('<P><LI><H4>'+question+'</H4>\n\n')
 
        # questions (Q:) can be continued by lines starting with |
        cont_q = re.search(r'^\|(.*)', line)
        if cont_q:
            # copy to output:
            text = cont_q.group(1)
            qa[question_counter-1].question = qa[question_counter-1].question \
                                              + '\n' + text
            htmlfile.write(text + '\n')
 
        answer_line = re.search(r'^A:\s*([A-Za-z\-]+)[\s\n]+(.*)', line)
    else:
        # some ordinary text that we copy "as is" to the HTML file,
        # but first check if it could be a tag with typo:
        m = re.search(r'^([A-Za-z]:)', line)
        if m:
            print 'Found a line starting with',m.group(1),\
                  ' (unknown tag), might be a typo'

src/s/r/srsbot-HEAD/example.py   srsbot(Download)
		if(message.sender==bot.nickname and message.type=="JOIN"): #See if you've joined a channel
			bot.privmsg(channel, "EXAMPLEBOT IS IN THE HIZZOUSE") #Send a private message to the channel
 
		if(re.search("hey examplebot", message.body, re.IGNORECASE)): #Use a regular expression to search the message body
			bot.privmsg(channel, "hey")
 
		if(re.search("what it do, dawg\?", message.body, re.IGNORECASE)):
			bot.privmsg(channel, "nothin much, man")
			bot.privmsg(channel, "nothin much")
 
		if(re.search("cool beans", message.body, re.IGNORECASE)):

src/p/y/pyjamas-0.7/examples/libtest/ReModuleTest.py   Pyjamas(Download)
        self.searchTest('test 7', 'Ab.cd', 0, 'AAAbXcd', ['AbXcd'], (2,7))
        self.searchTest('test 8', ' ', 0, 'Spaces in a sentence', [' '], (6,7))
 
        m = re.search("ab", "dab abba a b")
        self.assertFalse(m is None, """re.search("ab", "dab abba a b")""")
 
    # bug #258 - this is throwing a javascript syntax error in FF2

src/g/o/googletransitdatafeed-HEAD/python/test/testexamples.py   googletransitdatafeed(Download)
  def runTest(self):
    wiki_source = urllib.urlopen(
        'http://googletransitdatafeed.googlecode.com/svn/wiki/TransitFeed.wiki'
        ).read()
    m = re.search(r'{{{(.*import transitfeed.*)}}}', wiki_source, re.DOTALL)
    if not m:
      raise Exception("Failed to find source code on wiki page")

src/n/l/nltk-HEAD/nltk/examples/school/words.py   nltk(Download)
def print_conc(pattern, text, num=25):
    "Print segments of the file that match the pattern."
    for i in range(num):
        m = re.search(pattern, text)
        if not m:
            break
        print text[m.start()-30:m.start()+40]

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next