regex timeout error jquery / javascript -


i have content <del></del> , <ins></ins> tags. have regex satisfies conditions explained in image

http://i.stack.imgur.com/8inwl.png

the regex satisfies conditions is

https://regex101.com/r/ce4me3/19

this regex working fine. but, when content more or when matching content long execution time increasing , hence throwing timeout error can seen in regex101.com/r/ce4me3/20

how simplify regex (\w*(?:(?:(?:<del\b[^>]*>(?:(?!<\/del>).)*<\/del>)|(?:<ins\b[^>]*>\w+<\/ins>)|(?:\w+<\/ins>)|(?:<ins\b[^>]*>\w+))(?:\w+|))+) avoid throwing timeout error

regex not correct way this.you have discovered pitfall. there more.so switch dom parser .as removing timeout issue , can try

((?=(\w*))\2(?:(?:(?:<del\b[^>]*>(?:(?!<\/del>).)*<\/del>)|(?:<ins\b[^>]*>\w+<\/ins>)|(?:\w+<\/ins>)|(?:<ins\b[^>]*>\w+))(?:\w+|))+) 

see demo.

https://regex101.com/r/ce4me3/24


Comments