#π Regex to find up to three repeating characters, followed by a space
16 messages Β· Page 1 of 1 (latest)
@tranquil nova
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.
python re docs
{m,n}Causes the resulting RE to match from `m` to `n` repetitions of the preceding RE, attempting to match as many repetitions as possible. For example, `a{3,5}` will match from 3 to 5 `'a'` characters
so I'm pretty sure you can just match for [^#]#{1,3}
You might need some negative lookahead.
Caveat emptor: I'm not a regex person.
No, negative lookbehind.
'#{1,3}(?<!#{4})(?= )'```
Negative lookbehind and positive lookahead.
Because you didn't want the spaces.
Now...this gets the result...but.
I don't know how well it's going to hold up to more robust testing.
I don't know if this is good regex or crap regex.
But there's my go at it.
@tranquil nova
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.