Python Foundation

+91-7982108418            
           PYTHON REGULAR EXPRESSION QUESTION

1. Write a Python program to check that a string contains only a certain set of characters (in this case a-z, A-Z and 0-9).
2. Write a Python program that matches a string that has an a followed by zero or more b’s.
3. Write a Python program that matches a string that has an a followed by one or more b’s.
4. Write a Python program that matches a string that has an a followed by zero or one ‘b’.
5. Write a Python program that matches a string that has an a followed by three ‘b’.
6. Write a Python program that matches a string that has an a followed by two to three ‘b’.
7. Write a Python program to find sequences of lowercase letters joined with a underscore.
8. Write a Python program to find the sequences of one upper case letter followed by lower case letters.
9. Write a Python program that matches a string that has an ‘a’ followed by anything, ending in ‘b’.

10. Write a Python program that matches a word at the beginning of a string.
11. Write a Python program that matches a word at the end of string, with optional punctuation.
12. Write a Python program that matches a word containing ‘z’.
13. Write a Python program that matches a word containing ‘z’, not at the start or end of the word.
14. Write a Python program to match a string that contains only upper and lowercase letters, numbers, and underscores.
15. Write a Python program where a string will start with a specific number.
16. Write a Python program to remove leading zeros from an IP address.
17. Write a Python program to check for a number at the end of a string.
18. Write a Python program to search the numbers (0-9) of length between 1 to 3 in a given string.
19. Write a Python program to search some literals strings in a string.
20. Write a Python program to search a literals string in a string and also find the location within the original string                         where   the pattern occurs.
21. Write a Python program to find the substrings within a string.
22. Write a Python program to find the occurrence and position of the substrings within a string.
23. Write a Python program to replace whitespaces with an underscore and vice versa.
24. Write a Python program to extract year, month and date from a an url

25. Write a Python program to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
26. Write a Python program to match if two words from a list of words starting with letter ‘P’.
27. Write a Python program to separate and print the numbers of a given string.
28. Write a Python program to find all words starting with ‘a’ or ‘e’ in a given string.
29. Write a Python program to separate and print the numbers and their position of a given string.
30. Write a Python program to abbreviate ‘Road’ as ‘Rd.’ in a given string.
31. Write a Python program to replace all occurrences of space, comma, or dot with a colon.
32. Write a Python program to replace maximum 2 occurrences of space, comma, or dot with a colon.
33. Write a Python program to find all five characters long word in a string.

34. Write a Python program to find all three, four, five characters long words in a string.
35. Write a Python program to find all words which are at least 4 characters long in a string.
36. Write a python program to convert camel case string to snake case string.
37. Write a python program to convert snake case string to camel case string.
38. Write a Python program to extract values between quotation marks of a string.
39. Write a Python program to remove multiple spaces in a string.
40. Write a Python program to remove all whitespaces from a string.
41. Write a Python program to remove everything except alphanumeric characters from a string.
42. Write a Python program to find urls in a string.
43. Write a Python program to split a string at uppercase letters.

44. Write a Python program to do a case-insensitive string replacement.
45. Write a Python program to remove the ANSI escape sequences from a string.
46. Write a Python program to find all adverbs and their positions in a given sentence.
47. Write a Python program to split a string with multiple delimiters.
48. Write a Python program to check a decimal with a precision of 2.
49. Write a Python program to remove words from a string of length between 1 and a given number.
50. Write a Python program to remove the parenthesis area in a string.

51. Write a Python program to insert spaces between words starting with capital letters.
52. Write a Python program that reads a given expression and evaluates it.
53. Write a Python program to remove lowercase substrings from a given string.

Powered by BetterDocs

Contact Us
close slider

error: Content is protected !!