How can I combine the following RegExs into one expression?

I am using the following RegEx to remove HTML tags from a string

<[^>]*> 

However, this does not eliminate empty lines. I found this other RegEx that successfully removes any blank lines:

 [#Chr(13)##Chr(10)#]+ 

I tried to combine both:

 ReReplaceNoCase(arguments.string, "(<[^>]*>)([#Chr(13)##Chr(10)#]+)", "", "ALL") 

But that does not work. I use ColdFusion for this, which should explain the # signs.

I thought () used to group statements in RegEx, but it doesn't seem to work in my attempt to combine two expressions.

0
source share
2 answers

Assuming the two regular expressions work the way you want, you can combine them with alternation:

 <[^>]*>|[#Chr(13)##Chr(10)#]+ 

I strongly suspect that the regular expressions you posted are actually not working correctly. I would advise you not to use regular expressions to parse HTML, since HTML is not a common language. Use an HTML parser instead.

+1
source
 stripcr(ReReplaceNoCase(arguments.string, "(<[^>]*>)", "", "ALL")) 
+1
source

Source: https://habr.com/ru/post/1334992/


All Articles