JayBawankar

lp python commands

Feb 17th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.43 KB | None | 0 0
  1. import re
  2. fo = open("abc.txt", "r+")
  3. str = fo.read();
  4. fo2 = open("email.txt", "wb")
  5.  
  6. result = re.search('cricket',str)
  7. result2 = re.split(' ',str)
  8. result3 = re.sub('Cricket','football',str)
  9. result4 = re.findall('cricket',str)
  10. result5 = re.findall('.',str)
  11. result6 = re.findall('e$',str)
  12. result7 = re.findall('\w*',str)
  13. result8 = re.findall('^\w+',str)
  14. result9 = re.findall('\w+$',str)
  15. result10 = re.findall('[\b\w]',str)
  16. result11 = re.findall('[\d]+[-][\d]+[-][\d]+',str)
  17. result12 = re.findall('[\w]+[@][\w]+[.][\w]+',str)
  18. result13 = re.findall('[\d]+',str)
  19. result14 = re.findall('\([^\)]*\)',str)
  20. #fo2.write(repr(result12))
  21. if result:
  22.     print ("Search: "+result.group())
  23.     print (result.start())
  24.     print (result.end())
  25.     print ('Split: ')
  26.     print (result2)
  27.     print ('Substitute: '+result3)
  28.     #print (result4)
  29.     #print (result5)
  30.     #print (result6)
  31.     #print (result7)
  32.     #print (result8)
  33.     #print (result9)
  34.     #print (result10)
  35.     print ('Date: ')
  36.     print (result11)
  37.     print ('Email: ')
  38.     print (result12)
  39.     print ('Digits: ')
  40.     print (result13)
  41.     print ('Parenthesis: ')
  42.     print (result14)
  43. else:
  44.     print ('Not found')
  45.  
  46.  
  47. fo.close()
  48. fo2.close()
  49.  
  50.  
  51. """
  52. Search: cricket
  53. 84
  54. 91
  55. Split:
  56. ['Cricket', 'is', 'a', 'bat-and-ball', 'game', 'played', 'between', 'two', 'teams', 'of', 'eleven', 'players', 'each', 'on', 'a', 'cricket', 'field,', 'at', 'the', 'centre', 'of', 'which', 'is', 'a', 'rectangular', '22-yard-long', '(20', 'metres)', 'pitch', 'with', 'a', 'target', 'at', 'each', 'end', 'called', 'the', 'wicket', '(a', 'set', 'of', 'three', 'wooden', 'stumps', 'upon', 'which', 'two', 'bails', 'sit).', 'Each', 'phase', 'of', 'play', 'is', 'called', 'an', 'innings,', 'during', 'which', 'one', 'team', 'bats,', 'attempting', 'to', 'score', 'as', 'many', 'runs', 'as', 'possible,', 'whilst', 'their', 'opponents', 'bowl', 'and', 'field,', 'attempting', 'to', 'minimise', 'the', 'number', 'of', 'runs', 'scored.', 'When', 'each', 'innings', 'ends,', 'the', 'teams', 'usually', 'swap', 'roles', 'for', 'the', 'next', 'innings', '(i.e.', 'the', 'team', 'that', 'previously', 'batted', 'will', 'bowl/field,', 'and', 'vice', 'versa).', 'The', 'teams', 'each', 'bat', 'for', 'one', 'or', 'two', 'innings,', 'depending', 'on', 'the', 'type', 'of', 'match.', 'The', 'winning', 'team', 'is', 'the', 'one', 'that', 'scores', 'the', 'most', 'runs,', 'including', 'any', 'extras', 'gained', '(except', 'when', 'the', 'result', 'is', 'not', 'a', 'win/loss', 'result).\nThis', 'article', 'is', 'about', 'the', 'overall', 'concept', 'of', 'games', 'called', 'football.', 'For', 'specific', 'versions', 'of', 'the', 'game,', 'the', 'balls', 'themselves', 'and', 'other', 'uses', 'of', 'the', 'term,', 'see', 'Football', '(disambiguation).\n\nSeveral', 'codes', 'of', 'football.', 'Images,', 'from', 'top', 'to', 'down,', 'left', 'to', 'right:', 'association', 'football', '(soccer),', 'Australian', 'rules', 'football,', 'international', 'rules', 'football,', 'a', 'rugby', 'union', 'scrum,', 'rugby', 'league,', 'and', 'American', 'football.\nFootball', 'is', 'a', 'family', 'of', 'team', 'sports', 'that', 'involve,', 'to', 'varying', 'degrees,', 'kicking', 'a', 'ball', 'with', 'a', 'foot', 'to', 'score', 'a', 'goal.', 'Unqualified,', 'the', 'word', 'football', 'is', 'understood', 'to', 'refer', 'to', 'whichever', 'form', 'of', 'football', 'is', 'the', 'most', 'popular', 'in', 'the', 'regional', 'context', 'in', 'which', 'the', 'word', 'appears.', 'Sports', 'commonly', 'called', 'football', 'in', 'certain', 'places', 'include:', 'association', 'football', '(known', 'as', 'soccer', 'in', 'some', 'countries);', 'gridiron', 'football', '(specifically', 'American', 'football', 'or', 'Canadian', 'football);', 'Australian', 'rules', 'football;', 'rugby', 'football', '(either', 'rugby', 'league', 'or', 'rugby', 'union);', 'and', 'Gaelic', 'football.[1][2]', 'These', 'different', 'variations', 'of', 'football', 'are', 'known', 'as', 'football', 'codes.\njay811ab@gmail.com\nxyz@yx.com\n9997778881\n8080808080\n9823655666']
  57. Substitute: football is a bat-and-ball game played between two teams of eleven players each on a cricket field, at the centre of which is a rectangular 22-yard-long (20 metres) pitch with a target at each end called the wicket (a set of three wooden stumps upon which two bails sit). Each phase of play is called an innings, during which one team bats, attempting to score as many runs as possible, whilst their opponents bowl and field, attempting to minimise the number of runs scored. When each innings ends, the teams usually swap roles for the next innings (i.e. the team that previously batted will bowl/field, and vice versa). The teams each bat for one or two innings, depending on the type of match. The winning team is the one that scores the most runs, including any extras gained (except when the result is not a win/loss result).
  58. This article is about the overall concept of games called football. For specific versions of the game, the balls themselves and other uses of the term, see Football (disambiguation).
  59.  
  60. Several codes of football. Images, from top to down, left to right: association football (soccer), Australian rules football, international rules football, a rugby union scrum, rugby league, and American football.
  61. Football is a family of team sports that involve, to varying degrees, kicking a ball with a foot to score a goal. Unqualified, the word football is understood to refer to whichever form of football is the most popular in the regional context in which the word appears. Sports commonly called football in certain places include: association football (known as soccer in some countries); gridiron football (specifically American football or Canadian football); Australian rules football; rugby football (either rugby league or rugby union); and Gaelic football.[1][2] These different variations of football are known as football codes.
  62. jay811ab@gmail.com
  63. xyz@yx.com
  64. 9997778881
  65. 8080808080
  66. 9823655666
  67. Date:
  68. []
  69. Email:
  70. ['jay811ab@gmail.com', 'xyz@yx.com']
  71. Digits:
  72. ['22', '20', '1', '2', '811', '9997778881', '8080808080', '9823655666']
  73. Parenthesis:
  74. ['(20 metres)', '(a set of three wooden stumps upon which two bails sit)', '(i.e. the team that previously batted will bowl/field, and vice versa)', '(except when the result is not a win/loss result)', '(disambiguation)', '(soccer)', '(known as soccer in some countries)', '(specifically American football or Canadian football)', '(either rugby league or rugby union)']
  75. """
Add Comment
Please, Sign In to add comment