Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

What exactly should the result of \s*#[^"']+$ be? #12775

Open
Labels
awaiting triageAwaiting triage from a maintainer
@anywo

Description

What would you like to share?

Code

import re
a = """
py_path = os.path.abspath(sys.argv[0]) # Absolute path of the current script 
str = '#FFFFFF' # Color 
py_dir = os.path.dirname(py_path) # Directory where the current script is located 
"""
pattern = '\\s*#[^"\']+$'
regex = re.compile(pattern, flags=re.MULTILINE) if isinstance(pattern, str) else pattern
print(re.sub(regex, "", a))

Expected behavior


py_path = os.path.abspath(sys.argv[0])
str = '#FFFFFF'
py_dir = os.path.dirname(py_path)

Actual behavior


py_path = os.path.abspath(sys.argv[0])
str = '#FFFFFF'

VsCode Result(Consistent with my understanding)

Image

Js Result

Image

Java Result

Image

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting triageAwaiting triage from a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /