Advertisement
go6odn28

find_veareiable_in_sentece

Feb 20th, 2024
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4. pattern = r'\b_[A-Za-z0-9]+\b'
  5. matches = re.findall(pattern, text)
  6.  
  7. found_variable = [re.sub("_", "", match) for match in matches]
  8. print(','.join(found_variable))
  9.  
  10.  
  11.  
  12. ########################################################################################
  13. # import re
  14. # print(','.join([re.sub("_", "", match) for match in re.findall(r'\b_[A-Za-z0-9]+\b', input())]))
  15.  
  16.  
  17.  
  18. #####################################################################################
  19. # import re
  20. #
  21. # text = input()
  22. # matches = re.findall(r'\b_[A-Za-z0-9]+\b', text)
  23. # print(','.join([re.sub("_", "", match) for match in matches]))
  24.  
  25.  
  26.  
  27. #####################################################################################
  28. # import re
  29. #
  30. # found_variable = []
  31. # text = input()
  32. # pattern = r'\b_[A-Za-z0-9]+\b'
  33. # matches = re.findall(pattern, text)
  34. #
  35. # for match in matches:
  36. #     variable_name = re.sub("_", "", match)
  37. #     found_variable.append(variable_name)
  38. #
  39. # print(','.join(found_variable))
  40.  
  41.  
  42.  
  43. #####################################################################################
  44. # import re
  45. #
  46. # text = input()
  47. # final_lst = []
  48. # regex = r'\b_[A-Za-z0-9]+\b'
  49. # matches = re.findall(regex, text)
  50. #
  51. # for word in matches:
  52. #     new_word = word.replace('_', '')
  53. #     final_lst.append(new_word)
  54. #
  55. # print(','.join(final_lst))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement