sketch-extract-text
Version:
A Sketch plugin to extract text from layers that match a regular expression
16 lines (15 loc) • 376 B
JavaScript
export default function filterTextLayersByRegularExpression ({
textLayers,
regularExpression,
shouldMatchLayerContent
}) {
return textLayers.filter(function (textLayer) {
const layerContent = textLayer.text
return (
layerContent !== '' &&
regularExpression.test(
shouldMatchLayerContent ? layerContent : textLayer.name
)
)
})
}