2
My problem is this: I want to get different objects from one string, dividing them by the character ;
, except those in parentheses.
Example:
Linha1;
Linha2;
L i n h a 3;
(linha que não quero que apareça; outra; mais uma;)
Linha 4;
And it’s coming out like this array:
Lista1, Linha2, L i n h a 3, linha que não quero que apareça, outra, mais uma, linha 4
But I don’t want: line that I don’t want to appear", the "other" or the "one more be included in this array, or summarizing: I don’t want anything in parentheses to be included in the list.
Updating
No one is understanding what I want, here’s an example of my code in my language:
{
echo "Olá, mundo!";
echo "Aqui é outro bloco!";
def MeuTeste = "24055";
if 123 = 123 (echo "Executa isso!"; echo "isso também!";);
if 123 = 545 (echo "Não execute isso!"; echo "ignore isso!";);
pause;
}
Here is the structure that separates each statement
by character ;
:
For currentStatement As Integer = 0 To Statements.Split(Separator).Length - 1
Dim currentIndex As String() = Statements.Split(";"c)
Dim currentText As String = currentIndex(currentStatement)
.... comandos que executam o currentText
Correct was to return the values of this variable currentIndex
:
echo "Olá, mundo!"
echo "Aqui é outro bloco!"
def MeuTeste = "24055"
if 123 = 123 (echo "Executa isso!"; echo "isso também!";)
if 123 = 545 (echo "Não execute isso!"; echo "ignore isso!";)
pause
but that’s the problem, and it comes back this way:
echo "Olá, mundo!"
echo "Aqui é outro bloco!"
def MeuTeste = "24055"
if 123 = 123 (echo "Executa isso!"
echo "isso também!"
)
if 123 = 545 (echo "Não execute isso!"
echo "ignore isso!"
)
pause
Moral of the story, he separates everything between parentheses and my question is this: How do I not separate what’s in the parentheses? Anyway, I don’t want to exclude what’s in the parentheses, but just don’t separate each thing by the character ;
.
In BASIC (Visual Basic) it would be the same expression?
– CypherPotato
The regular expression is the same, a regular expression is a domain-specific language, which changes to Visual Basic, is that you should use: Regex.Split (String, String); https://msdn.microsoft.com/pt-br/library/8yttk7sy(v=vs.110). aspx? Cs-save-lang=1&Cs-lang=Vb#code-snippet-1 .
– Filipe Miranda
Philip, I may be wrong but you’re sure you’re wrong regex works? for she is marrying even within parentheses. In the question Cypher preferred the languages C# and Vb. NET, the your code is in Java.
– stderr
What happens is that the Regular Expression is also a Language, but not of programming, and it is taken as a Domain Specific Language. There is a reference in my reply to a code in Visual Basic. Languages are just engines, this Web System has always worked for me. And yes, this regular expression works yes: (;|\(.\)) It is that in Java, we have to put one more bar as Escape character, so in fact the expression is this: (;|(.)) I will update the reply. Thank you.
– Filipe Miranda
@Filipegonzagamiranda Your regex yet doesn’t work, nor in Java, nor in C#. When referring to someone, use the
@
in front.– stderr
Sorry, I made a mess @qmechanik (;|\(.*\))
– Filipe Miranda
@qmechanik The Stack overflow engine is erasing the bar.... rsrs - It was good that I learned (;| (.* )) Same Java logic... I used two here, but you will see only one now
– Filipe Miranda
@Filipegonzagamiranda In Java the expression
(;|\(.*\))
works!, however in .NET. =/ maybe they’re Engines different, not sure.– stderr
@Filipegonzagamiranda If possible make explicit in the answer that expression
(;|\(.*\))
does not work in the .NET.– stderr
Well, I haven’t really tested it yet, I still don’t have the project here with me, I’ll be here today and I’ll pass the answer.
– CypherPotato
Well, since that regex there doesn’t work, as it would be in .NET?
– CypherPotato