#๐ Regex issue
19 messages ยท Page 1 of 1 (latest)
@regal forge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
I have a regex issue with my python code:
It ment to match ?i= it works on regex 101 but not python
import re
# Define the regex pattern
pattern = r'/(?<=\?i=)[^"\s]+/';
try:
# Open the file and read its contents
with open('test.txt', 'r') as file:
content = file.read()
# Find all matches
matches = re.findall(pattern, content)
# Print the matches
print("Found matches:")
for i, match in enumerate(matches, 1):
print(f"Match {i}: {match}")
except FileNotFoundError:
print("Error: The file 'test.txt' was not found.")
except IOError as e:
print(f"Error reading the file: {e}")
except re.error as e:
print(f"Regex error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
do you have the link to regex 101 with the pattern and the sample content that it matches on?
How can I give you a link?
you're using the wrong regex
no problem
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Regex issue