0

I have string that can be like

  • "blahblah...blah"
  • "blahblah...blah";12
  • -12.4;"blah";"TRUE".

Basically there can be any number or elements in string separated with ";" (if more then one element) where elements are names enclosed with " or numbers.

I have tried to create a pattern here, but I don't know how to include check that to know delimiter is ; character.

For reference string and pattern are:

word = '"dadada";-15.7;15;"TRUE"'
p = r'(?:\"\w+\"|[+-]?\d{1,3}\.?\d{1})+'

Edit: What I would like to do is extract data between ; if exists and I thought maybe this can be done with regex. Data in not read from csv file.

flebas
  • 99
  • 8
  • Do you want to separate these items? Have a look at e.g. `pandas.read_csv()` with `sep=;`. – Jan May 23 '17 at 07:20
  • 1
    See https://stackoverflow.com/questions/3305926/python-csv-string-to-array – Wiktor Stribiżew May 23 '17 at 07:21
  • What are you trying to achieve with the regex? You want to split the string by the delimiter ? Write in the question what you are trying to achieve as well. It might be that there are better ways to achieve it than regex. – Foryah May 23 '17 at 07:22

0 Answers0