I work on projects it works fine but when I add value color then it doesn't work?
here is my Js Fiddle Link, when we use #color=(#333) then it should change the color of the background button but it doesn't
same like in #size=(1) it adds a class in button but now the code doesn't work
I just add regex function and the code stopped working Please check the jsFiddle
here these lines of code stop working
var color = getAttr(info, "color");
var size = getAttr(info, "size");
While the rest of the code works fine, Any help or advice is highly appreciated.
CodePudding user response:
You regex seems wrong on the second-half
/(?:(\#[a-zA-Z]{4,})=\(([a-z A-Z]{4,})\))/g
This would indicates the string should have
- hash
#
- letter-ONLY character (minimum 4 characters)
- equal
=
- another letter-ONLY character (minimum 4 characters) in brackets
Thus, your example #color=(#333)
not working bcoz it has hash #
and #size=(1)
not working bcoz it is not letter and only have 1 character.
SOLUTION: You should use like this instead:
/(?:(\#[a-zA-Z] )=\(([^\)] )\))/g