C#C
C#3y ago
Chris TCC

✅ help with regex

I'm trying to learn regex, have watched multiple tutorials and checked multiple websites, but can't fully grasp how to use it for my specific situation.
I want to find and retrieve a certain part out of a string: the word that follows an @.
currently I have this:
^@[a-zA-Z0-9]+$
Here are some example cases:
word @something -> true
@something -> true
word@something -> false
I'd like to be able to retrieve the @something from those examples, whilst ignoring the rest. Would my regex work? I've tried it with this website (https://regexr.com) but it doesn't seem to work...
RegExr
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
Was this page helpful?