Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**Regex Pattern**
1. <img : looks for <img in text
2. \w : looks for any word character (equivalent to [a-zA-Z0-9_])
3. \W : looks for any non-word character (equivalent to [^a-zA-Z0-9_])
4. '>' : looks for character >

**How to use**
1. Run this query in background/Fix scripts.
2. The info message will return articles having images. This is very useful information when there are broken images in articles after movement between instances or tools.
3. This can be further enhanced to replace image src if required.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
This code will search for img tag in kb articles.
Regex Patterns:
<img : looks for <img in text
\w : looks for any word character (equivalent to [a-zA-Z0-9_])
\W looks for any non-word character (equivalent to [^a-zA-Z0-9_])
> : looks for character >
*/
var kbArt = new GlideRecord('kb_knowledge');
kbArt.addEncodedQuery('workflow_state=published'); // encoded get publiushed acticles.
kbArt.query();
while (kbArt.next()) {
var imgRegex = /<img([\w\W]+?)>/; // Regex for checking img tag.
var regex = new RegExp(imgRegex); // forming regex using SN.
if (kbArt.getValue('text') && regex.test(kbArt.getValue('text'))) { // if article body is not empty and has image tag.
gs.info("Image is found in KB Article: " + kbArt.getValue('number'));
}
}
Loading