I'm trying to capture the username for the following input string in GoLang regex, I expected anonymous and prettygurl91 to be in a single group, but it wasn't the case for the following pattern.
Input:
[Twitter] An anonymous user has posted a photo on 03-24-2024!
[Twitter] User prettygurl91 has posted a video on 03-25-2024!
Pattern:
^\[Twitter\] (?:User (.*?)|An (anonymous) user) has posted a (.*) on (.*)\!
Resulting groups:
Resulting group for [Twitter] An anonymous user has posted a photo on 03-24-2024!
- Nil
- anonymous
- photo
- 03-24-2024
Resulting group for [Twitter] User prettygurl91 has posted a video on 03-25-2024!
- prettygurl91
- Nil
- video
- 03-25-2024
What is was expecting was the following input strings to be grouped like so
- prettygurl91 / anonymous
- photo / video
- 03-24-2024 / 03-25-2024
Solved with the following regex pattern