Python Forum
Who enjoys Py RegEx? re.sub() isn't working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Who enjoys Py RegEx? re.sub() isn't working
#5
(Jun-08-2020, 05:49 AM)goodsignal Wrote: re.search() will return the extent of the pattern match, which could be a sub-string of the input.

Basically, yes. Technically, it returns a match object, which includes the start/end/span and any capturing groups (among other things).

Quote:re.sub() will return the entire input, only replacing the portion that matches the regex pattern.

Yup. (And by default, the replacement can happen multiple times. While re.search() will only match the leftmost position).
Reply


Messages In This Thread
RE: Who enjoys Py RegEx? re.sub() isn't working - by bowlofred - Jun-08-2020, 06:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Regex to extract IPs between () not working mrapple2020 5 3,589 Apr-12-2019, 08:03 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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