-2

I have a list of strings like below.

arr = ['U.S.A','Ph.D','Mr.']

I would like to clean this array of the period so that the output would be like

arr = ['USA','PhD','Mr']

Is there a clean regex way to do this?

SierraD
  • 11
  • What have you tried so far? – Mehrdad Pedramfar Feb 20 '19 at 12:38
  • You could use `map`, a higher order function which allows you to control the mapping of array elements to a new array, which allows you to control how each element should be converted `new_arr = list(map(lambda str: str.replace('.', ''), arr))` – Nick Parsons Feb 20 '19 at 12:46

1 Answers1

2

If it's just dots, you don't need a regex:

[x.replace('.', '') for x in arr]
match
  • 10,388
  • 3
  • 23
  • 41