0
This expression is cutting HTML only when I put it at the beginning of the expression. How to fix this?
(?:[ \t]*[a-z][)]\s*)?([^\r\n<]+(?:(?:\r?\n(?!\s*[a-z][)])|<(?!br\s*\/?>(?:\s*<br\s*\/?>)*\s*(?:\s+[a-z][)]|\s*$)))[^\r\n<]*)*)(?:<br\s*\/?>\s*)*
questao=Request.Form("questao")
'RegEx
Set re = New RegExp
re.Global = true
re.IgnoreCase = true
re.Pattern = "(?:[ \t]*[a-z][)]\s*)?([^\r\n<]+(?:(?:\r?\n(?!\s*[a-z][)])|<(?!br\s*\/?>(?:\s*<br\s*\/?>)*\s*(?:\s+[a-z][)]|\s*$)))[^\r\n<]*)*)(?:<br\s*\/?>\s*)*"
Set matches = re.Execute(questao)
If (matches.Count) Then
'PERGUNTA
pergunta=(matches(0).SubMatches(0))
Response.Write(pergunta)
'RESPOSTAS
For m = 1 To matches.Count - 1
Response.Write(matches(m).SubMatches(0))
resposta_a=matches(1).SubMatches(0)
resposta_b=matches(2).SubMatches(0)
resposta_c=matches(3).SubMatches(0)
resposta_d=matches(4).SubMatches(0)
resposta_e=matches(5).SubMatches(0)
Next
End If
Set matches = Nothing
Set re = Nothing
%>
Are you sure you want to treat HTML with regex?
– Woss
Maybe I expressed myself wrong. I want to include the "<" of Strong in the expression. See that it is outside.
– Rod
But what is the purpose of REGEX? Perhaps there is a simpler solution.
– Woss
This expression separates the question and all the answers (a,b,c,d,e), then I will give an input in the bank, but when, for example format her first word, the beginning of htlm ("<") is cut. Got it?
– Rod
Put the text on is to be applied to regex here in the question, so that its purpose is clearer. And also detail what at this point you get for what you wanted you to get. The more detailed the more likely you are to find a satisfactory answer.
– Isac
@Isac Has a link in the question that goes straight to expression and text all assembled. If you click on it will understand.
– Rod
I saw the link, but it doesn’t invalidate what I said. Not only do I have to open a link on a new page, to try to guess what you’re trying to capture, and therefore guess what’s not right. The more you clarify the better results you get.
– Isac
@Isac’s okay buddy, I’m sorry.
– Rod
These questions come from a relational database? Because if they come I think this idea of putting together the questions in question everything in the same field is a bad strategy of how the bank was planned, I would personally make a table for the questions related to a table for the options, so in case of removing options or edit-las would not need to be doing "parser" with regex
– Guilherme Nascimento
@Guilhermenascimento is just the opposite of what you’re saying. I take the whole question, play in an editor type fckeditor, format it, separate with REGEX and insert in the bank in separate fields. This is my idea. field_question, answer_1, answer_2 and so on.
– Rod
@Rod this was the intention even, but I do not think invalido try to resort to this, I have even a suggestion maybe I formulate an answer tomorrow.
– Guilherme Nascimento