开发者

Regex for dashed class names

开发者 https://www.devze.com 2023-03-31 16:44 出处:网络
I have a strings that looks like this: \"wes-1 className Another\" \"wes-2-bos className Another\" \"wes-3 className Another\"

I have a strings that looks like this:

"wes-1 className Another" "wes-2-bos className Another" "wes-3 className Another" "wes-5-bos className Another"

I need to return the ones that are wes-* and delete everything else.

Regex makes my head spin, any help?

using js. This开发者_运维百科 is what I have so far..

str.match(/\b^wes/);


str.match(/wes-[\w-]*/)

matches wes- and any number of word or - characters after it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号