-3

I have string for example

subject = '=?UTF-8?Q?=C5=A0irvint=C5=B3_PSPC_ir_TENESYS_3CX_RESTful_API?='

I want to split it by '?=' and it working ok if there is only 1 '?=' my string, but when I have more than 1 I'm getting problems. I know that I can split my string skipping that ?= that is going after "=?UTF-8?Q"

this is my code

 for split_begin in subject.split('=?'):
                for split_end in split_begin[:2].split('?='):
                    if 'UTF-8' in split_end:
                        special_word = '=?' + split_end + '?='
                        word_list.append(special_word)

UPDATE.

when string is '=?UTF-8?Q?=C5=A0irvint=C5=B3_PSPC_ir_TENESYS_3CX_RESTful_API?='

split end = 'UTF-8?Q' 

this is bad output.

when string is `subject = '=?UTF-8?Q?D=C4=97l_greito_va=C5=BEiavimo?='

split end = 'UTF-8?Q?D=C4=97l_greito_va=C5=BEiavimo'

this is good output.

different in the string that second string has only 1 ?= in it

Chaban33
  • 1,362
  • 11
  • 38

1 Answers1

0

I don't quite understand what you want to accomplish, but !

subject.split('?=') will give you the output you want - meaning it will split your string according to the seperator you gave it.

i think that your problem occur since you accidentally wrote :

subject.split('=?') instead of subject.split('?=')

hope it helps.

ddor254
  • 1,570
  • 1
  • 12
  • 28