0

Trying to ignore all characters until ":" then select everything until "}"

Having a hard time with it.

So basically the following:

.#{$fa-css-prefix}-500px:before { content: fa-content($fa-var-500px); }
.#{$fa-css-prefix}-accessible-icon:before { content: fa-content($fa-var-accessible-icon); }
.#{$fa-css-prefix}-accusoft:before { content: fa-content($fa-var-accusoft); }

needs to look like:

-500px
-accessible-icon
-accusoft

Have the following working partially here: https://regex101.com/r/QN8gl2/3

Any help would be appreciated.

webkitfanz
  • 1,305
  • 1
  • 16
  • 29
  • Have you tried `\.[#]\{[$]fa\-css\-prefix\}-(.*?):.*` ? – Ultimater Dec 12 '17 at 06:58
  • That selects everything. – webkitfanz Dec 12 '17 at 07:00
  • 1
    Oops, that should be `\.[#]\{[$]fa\-css\-prefix\}(\-.*?):.*` to also include the dash. But if you check the regexp results, it shows Group 1 has what you're trying to match. Otherwise if you don't want to use groups, you're looking for a look-behind and look-ahead combination: `(?<=})-.*?(?=:)` note that JavaScript doesn't support lookbehinds. – Ultimater Dec 12 '17 at 07:07
  • Why not just `\}[^:]*`? – melpomene Dec 12 '17 at 07:09

1 Answers1

0
\.#{[$]fa-css-prefix}-(.+?):

And you just need to get group 1!

Note that I used a lazy quantifier here since a greedy one will cause a lot of backtracking.

If you are not sure how to get group 1, refer to this.

Alternatively, you can use the substitution approach,

\.#{[$]fa-css-prefix}-(.+?):.+

Replace with

$1

Try it here: https://regex101.com/r/QN8gl2/5

Sweeper
  • 213,210
  • 22
  • 193
  • 313
  • so there is no way to do this without replace with? For instance if I wanted to do this with jquery, how will this work? Where would I insert '$1'? – webkitfanz Dec 12 '17 at 07:14
  • @webkitfanz As I said, you can get group 1 if you use the first regex. – Sweeper Dec 12 '17 at 07:15