Python-get string between to characters

后端 未结 4 436
悲哀的现实
悲哀的现实 2021-01-29 14:07

I need to one give me the string between ~ and ^.
I have a string like this:

~~~~ ABC ^ DEF ^ HGK > LMN ^  

I

4条回答
  •  感情败类
    2021-01-29 14:34

    I'm not sure exactly what result is desired, but perhaps this?

    >>> matchObj = re.findall(r'~+(.*?)\^', target)
    >>> print(matchObj)
    [' ABC ']
    

提交回复
热议问题