How do I use Regex to remove "Sensor_" from a data set? this is example set, ["Sensor_01", "Sensor_10"}

StackOverflow https://stackoverflow.com/questions/15206942

  •  18-03-2022
  •  | 
  •  

문제

How do I use Regex to remove "Sensor_" from a data set? this is example set, ["Sensor_01", "Sensor_10"}

??

I am having some trouble with understanding all the symbols, (dyslexia)

도움이 되었습니까?

해결책

like this:

dataset = ['Sensor_01', 'Sensor_02', 'Sensor_03']
for i in range(len(dataset)):
    dataset[i] = dataset[i].replace('Sensor_', '')
print dataset

다른 팁

No need for regex here, simply replace all instances of "Sensor_" with nothing. This should help.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top