问题
I'm using the following RegEx to strip HTML tags from a string
<[^>]*>
This does not get rid of blank lines, however. I found this other RegEx that successfully removes any blank lines:
[#Chr(13)##Chr(10)#]+
I tried to combine both as such:
ReReplaceNoCase(arguments.string, "(<[^>]*>)([#Chr(13)##Chr(10)#]+)", "", "ALL")
But this does not work. I'm using ColdFusion to do this, which should explain the # signs.
I thought the () were used to group operators in RegEx, but it does not seem to work in my attempt to combine the two expressions.
回答1:
Assuming that the two regular expressions you have work as you want then you can combine them using an alternation:
<[^>]*>|[#Chr(13)##Chr(10)#]+
I strongly suspect though that the regular expressions you have posted don't in fact work correctly. I'd advise you not to use regular expressions to parse HTML as HTML is not a regular language. Use an HTML parser instead.
回答2:
stripcr(ReReplaceNoCase(arguments.string, "(<[^>]*>)", "", "ALL"))
来源:https://stackoverflow.com/questions/4540036/how-can-i-combining-the-following-regexs-into-one-expression