Taylor Foster
Taylor Foster

Reputation: 1215

Regex that grabs all occurrences of strings that start with '@'

I am new to writing Regular Expressions and I'm building an app that needs to look for all occurrences of the @ symbol and the rest of the string. For example:

.btn-primary{
 color: @color;
 background-color: @background-color;
 font-size: 1.5em;
 font-weight: bold;
 &:hover{
  background-color: darken(@background-color, 15%);
 }
}

I would like a regex that would search this LESS code and return to me all FULL strings that start with @. I tried doing this with an online regex builder and came up with /\A@\S*/ but I'm almost sure that is not correct.

Thank You For Your Help!

Upvotes: 1

Views: 31

Answers (1)

Code Different
Code Different

Reputation: 93161

Try this pattern:

(@[a-zA-Z-]+)

Regex101

Upvotes: 1

Related Questions