Answered
GREP search problems
Hello. I have a trouble with grep search. When searching manually it works, but when i try to use js script it applyes only the last pattern from three. I do not understand why.
// Run the script
var doc = app.activeDocument;
var charStyleName = "dontChange";
// Create or retrieve the character style once
var charStyle = getOrCreateCharacterStyle(doc, charStyleName);
var extentions = "(txt|md|rtf|doc|docx|odt|xls|xlsx|csv|ppt|pptx|pdf|epub|mobi|jpg|jpeg|png|gif|bmp|tiff|svg|ai|eps|mp3|wav|flac|mp4|mkv|avi|mov|zip|rar|7z|tar|gz|iso|html|css|js|json|xml|sql|sh|bat|ps1|exe|dll|sys|ini|log|dmp|indd|idml|dwg|dxf|ttf|otf|woff|woff2|eot)"
// Define patterns to apply the character style
var patterns = [
"\\<[^[:space:]]+://[^[:space:]]*\\>",
"\\<[^[:space:]]+@[^[:space:]]*\\>",
"\\<[^[:space:]]+\\." + extentions + "+[^[:space:]]*\\>"];
for (var j = 0; j < patterns.length; j++) {
// Set the pattern and search with GREP
app.findTextPreferences.findWhat = patterns[j];
applyCharacterStyle(doc, patterns[j], charStyle);
}
Thank you.
Thank you.
