Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 35941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:18:53+00:00 2026-05-10T14:18:53+00:00

The Python docs say: re.MULTILINE: When specified, the pattern character ‘^’ matches at the

  • 0

The Python docs say:

re.MULTILINE: When specified, the pattern character ‘^’ matches at the beginning of the string and at the beginning of each line (immediately following each newline)… By default, ‘^’ matches only at the beginning of the string…

So what’s going on when I get the following unexpected result?

>>> import re >>> s = '''// The quick brown fox. ... // Jumped over the lazy dog.''' >>> re.sub('^//', '', s, re.MULTILINE) ' The quick brown fox.\n// Jumped over the lazy dog.' 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:18:54+00:00Added an answer on May 10, 2026 at 2:18 pm

    Look at the definition of re.sub:

    re.sub(pattern, repl, string[, count, flags]) 

    The 4th argument is the count, you are using re.MULTILINE (which is 8) as the count, not as a flag.

    Either use a named argument:

    re.sub('^//', '', s, flags=re.MULTILINE) 

    Or compile the regex first:

    re.sub(re.compile('^//', re.MULTILINE), '', s) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Any page with a MasterPage, whether it is in SharePoint… May 11, 2026 at 11:40 am
  • added an answer The option type is at least similar to Nullable<T> and… May 11, 2026 at 11:40 am
  • added an answer PsExec, a part of PsTools, can do this for you. May 11, 2026 at 11:40 am

Related Questions

The Python docs say: re.MULTILINE: When specified, the pattern character '^' matches at the
The python 2.6 docs state that x % y is defined as the remainder
I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a
In Python 2.6, a new timeout parameter was added to the httplib.HTTPConnection class: http://docs.python.org/library/httplib.html#httplib.HTTPConnection
The Python list comprehension syntax makes it easy to filter values within a comprehension.
Using the Python Documentation I found the HTML parser but I have no idea
In the Python documentation it says: A thread can be flagged as a daemon
The documentation of the Python readline module says Availability: Unix. However, it doesn't appear
In the python program I'm writing, I've got a thread which iterates over a
Is there something like the Python descriptor protocol implemented in other languages? It seems

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.