-2

Here is the the Mardown text..

![sample text](/api/article/58933542dbac1da7eba747e0/file/58933542dbac1da7eba747e1/binary/A3DD9420-C5BA-426A-A51A-296C263440FF.png).fgfgfdgdfgdfgfg fg.<video controls poster='tempfile://827e9ff4-07ef-f9c1-a4c2-5d4f8fcb5754'><source src='tempfile://d23228e7-a683-befc-724b-96f57f5459e7' type='video/mp4'></video>

In the above string need to replace

 <video controls poster='tempfile://827e9ff4-07ef-f9c1-a4c2-5d4f8fcb5754'><source src='tempfile://d23228e7-a683-befc-724b-96f57f5459e7' type='video/mp4'></video>

with empty using javascript (Replace) regular expression..

 function RemoveContentText(text, link) {
    return text.replace(/(!\[.*?\]\()(.+?)(\))/g, function (whole, a, b, c)  {

        if (whole == link) return '';
        else return whole;
    });
}

Here text is the Mardowntext and link is the string which needs to be replaced by empty..

Sagar Jagadesh
  • 237
  • 5
  • 14

2 Answers2

1

Maybe like this:

/<\s*video[^>]*>\s*(?:<\s*source[^>]*>\s*)*<\s*\/\s*video\s*>/ig

It should match all possible video tags with only source tags inside of them.

regexr.com is a good place for testing such regular expressions.

Siphalor
  • 712
  • 5
  • 16
0

You can give a try with indexOf() to get the indexes of video tag and then try replacing. Example for find:

var str = "Hello world, welcome to the universe."; var n = str.indexOf("welcome"); answer: 13

replacing with index position

Community
  • 1
  • 1
Santosh Ksl
  • 162
  • 2
  • 10