AnsweredAssumed Answered

Extract only numbers and strings in long string

Question asked by Dave.J on Jul 11, 2016
Latest reply on Jul 12, 2016 by Dan_Patterson


Hi,

   I am trying to extract all numbers and string from a long string and store them in a array, but the my expressing always split a decimal number and make all integer numbers. Codes like following

 

# -*- coding: cp1252 -*-

import re

DATA = r"26°48'18.3431\"E  39°36'6.979\"N"

print re.findall(r"[\d+\w+]+", DATA)

 

 

it returns  ['26', '48', '18', '3431', 'E', '39', '36', '6', '979', 'N']

I want the statement returns ['26', '48', '18.3431', 'E', '39', '36', '6.979', 'N']

 

Can anyone help?

Thanks.

Dave

Outcomes