Python Forum
[SOLVED] Why does regex fail cleaning line?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Why does regex fail cleaning line?
#1
Hello,

I can't figure out why this regex fails editing an XML header:

with open(INPUTFILE) as reader:
	content = reader.read()
#I need to just get <gpx>
#OK content = re.sub('<gpx', '<BLAH', content)
#BAD content = re.sub('<gpx.+?>', '<gpx>', content,re.MULTILINE)
#BAD content = re.sub('<gpx.+?>', '<gpx>', content,re.MULTILINE|re.DOTALL)
#BAD content = re.sub('<gpx.+?>', '<gpx>', content,re.MULTILINE|re.DOTALL|re.IGNORECASE)
Any idea what I could try?

Thank you.
Reply


Messages In This Thread
[SOLVED] Why does regex fail cleaning line? - by Winfried - Aug-22-2021, 02:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] Regex expression do not want to taken :/ SpongeB0B 2 774 Nov-06-2023, 02:43 PM
Last Post: SpongeB0B
  Why does [root.destroy, exit()]) fail after pyinstaller? Rpi Edward_ 4 636 Oct-18-2023, 11:09 PM
Last Post: Edward_
  Cleaning my code to make it more efficient BSDevo 13 1,381 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Help with a regex? (solved) wrybread 3 837 May-01-2023, 05:12 AM
Last Post: deanhystad
  [SOLVED] [regex] Why isn't possible substring ignored? Winfried 4 1,076 Apr-08-2023, 06:36 PM
Last Post: Winfried
  [SOLVED] Alternative to regex to extract date from whole timestamp? Winfried 6 1,852 Nov-16-2022, 01:49 PM
Last Post: carecavoador
  How to calculated how many fail in each site(s) in csv files SamLiu 4 1,307 Sep-26-2022, 06:28 AM
Last Post: SamLiu
  regex multi-line kucingkembar 6 1,584 Aug-27-2022, 10:27 PM
Last Post: kucingkembar
  Apply textual data cleaning to several CSV files ErcoleL99 0 846 Jul-09-2022, 03:01 PM
Last Post: ErcoleL99
  Imports that work with Python 3.8 fail with 3.9 and 3.10 4slam 1 2,602 Mar-11-2022, 01:50 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020