This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
pattern=re.compile('my') | |
result=pattern.findall('my name is naveen') | |
print result | |
result2=pattern.findall('Hi Hi This is codersarts') | |
print result2 | |
Output | |
['my'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
s = "HELLO there HOW are YOU" | |
l = re.compile("(?<!^)\s+(?=[A-Z])(?!.\s)").split(s) | |
print l | |
Output: | |
['HELLO there', 'HOW are', 'YOU'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = "Python for beginner is a very cool website" | |
pattern = re.sub("cool", "good", text) | |
print text2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re.subn (pattern, repl, string, count=0, flags=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
print re.escape("Hello 123 .?!@ World") | |
output: | |
Hello\ 123\ \.\?\!\@\ World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
m = re.search('(?<=abc)def', 'abcdef') | |
m.group(0) | |
Output: | |
'def' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
value = "voorheesville" | |
m = re.match("(vi.*)", value) | |
if m: | |
print("match:", m.group(1)) | |
Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
regex = ur"\[P\] (.+?) \[/P\]+?" | |
line = "President [P] Barack Obama [/P] met Microsoft founder [P] Bill Gates [/P], yesterday." | |
person = re.findall(regex, line) | |
print(person) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
from tkinter import ttk | |
import time | |
import datetime | |
from PIL import ImageTk,Image | |
import os | |
import sqlite3 | |
from tkinter import messagebox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Codersarts by NK | |
import numpy as np | |
li = [[1,2,3], [5,6,7], [6,7,8]] | |
nparray = np.array(list2) | |
nparray |