Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anywo opened this issue May 30, 2025 · 1 comment
Open

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

anywo opened this issue May 30, 2025 · 1 comment
Labels
awaiting triage Awaiting triage from a maintainer

Comments

@anywo
Copy link

anywo commented May 30, 2025

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

@anywo anywo added the awaiting triage Awaiting triage from a maintainer label May 30, 2025
@anywo
Copy link
Author

anywo commented May 30, 2025

\S * # [^ "']+? $ is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting triage Awaiting triage from a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant