Search CSS (and CSS-like) strings, with sensitivity to whether matches occur inside strings, comments, and functions.
var styleSearch = ;;
By default, the search ignores strings, comments, and function names. You can use the options to change this behavior or introduce other restrictions. That is what makes this module more useful for many searches than
indexOf() or a
/* Here is some pink */
For every match found your
callback is invoked. It is passed two arguments:
matchobject with the following properties:
startIndex: where the match begins
endIndex: where the match ends
target: what got matched (useful if your
targetoption is an array instead of a single string)
insideFunctionArguments: whether the match is inside a function — this includes the parentheses around the arguments
insideComment: whether the match is inside a comment
insideString: whether the match is inside a string
- The count of how many matches have been found up to this point.
Below you'll see that syntax feature options all accept three keywords:
"only". An error will be thrown if you use
"only" more than once.
The source string to search through.
String or array of strings. Required.
The target of the search. Can be
- a single character
- a string with some length
- an array of strings, all of which count as matches (the
matchobject passed to the
callbackwill differentiate which string in the array got matched via its
true, the search will stop after one match is found.
This includes both standard
/* CSS comments */ and non-standard but widely used
// single line comments.
This designates anything inside parentheses, which includes standard functions, but also Sass maps and other non-standard constructs.
parentheticals is a broader category than