V
V
Vladislav Gladkiy2016-02-18 17:25:03
Regular Expressions
Vladislav Gladkiy, 2016-02-18 17:25:03

Regexp for BEM?

There is a regular expression /\b([a-z\d-]+(?:__[a-z\d-]+)*)\b/ig
that finds blocks and elements without modifiers, but if the name is present -, then everything breaks. (example: regexr.com/3cr4d , correct behavior below)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alameya, 2016-03-04
@alameya

https://regex101.com/r/bI6cN5/1
/\b((?:[a-z0-9-]+)(?:__[a-z0-9-]+)*)\b/ig

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question