how to remove text between [removed] and [removed] using python?

后端 未结 9 763
眼角桃花
眼角桃花 2021-02-04 19:19

how to remove text between using python?

9条回答
  •  萌比男神i
    2021-02-04 19:59

    example_text = "This is some text  this is some more text."
    
    import re
    myre = re.compile("(^.*)(.*$)")
    result = myre.match(example_text)
    result.groups()
      <52> ('This is some text ', ' blah blah blah ', ' this is some more text.')
    
    # Text between 
    result.group(2)
      <56> 'blah blah blah'
    
    # Text outside of 
    result.group(1)+result.group(3)
      <57> 'This is some text  this is some more text.'
    

提交回复
热议问题