diff --git a/Specialized Areas/Regular Expressions/Img Tag Regex validator/README.md b/Specialized Areas/Regular Expressions/Img Tag Regex validator/README.md new file mode 100644 index 0000000000..8e6f15e726 --- /dev/null +++ b/Specialized Areas/Regular Expressions/Img Tag Regex validator/README.md @@ -0,0 +1,10 @@ +**Regex Pattern** +1. ' : 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. diff --git a/Specialized Areas/Regular Expressions/Img Tag Regex validator/script.js b/Specialized Areas/Regular Expressions/Img Tag Regex validator/script.js new file mode 100644 index 0000000000..5e03904657 --- /dev/null +++ b/Specialized Areas/Regular Expressions/Img Tag Regex validator/script.js @@ -0,0 +1,18 @@ +/* +This code will search for img tag in kb articles. +Regex Patterns: + : 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 = //; // 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')); + } +}