regex stop if the charactere next is another

1

Next: I have this text for example

aluno['ACERTOS_ATV2_D2'] >5.5 & aluno['IDADE'] >24.5 & aluno['PROVA1_D2P'] <0.5 & aluno['ASSISTIU_AULA_1_D2'] <0.5 & aluno['FEZ_FORUM_D2SIM'] > 0.5

I need to make a regex that will change that part into a batch. for example, this

aluno['PROVA1_D2P'] <0.5** deve ficar **aluno['PROVA1_D2'] != 'P'** (aqui é != pois o simbolo é de menor <) and aluno['FEZ_FORUM_D2SIM'] > 0.5** deve ficar aluno['FEZ_FORUM_D2'] == 'SIM'** (aque é == pois o simbolo é >)

I'm doing 2 regex, one for each symbol of > & lt ;. No problem making 2x. The first replacement works, but when I go to do the second, it's the problem.

My regex looks like this:

/(PROVA1_D2|FEZ_FORUM_D2)(.*?)\]\s\<\d\.\d/g
o replace está $1'] == '$2

aluno['ACERTOS_ATV2_D2'] >5.5 & aluno['IDADE'] >24.5 & aluno['**PROVA1_D2'] != 'P'** & aluno['ASSISTIU_AULA_1_D2'] <0.5 & aluno['FEZ_FORUM_D2SIM'] >0.5

So far okay, all right, but when I go to do the second part (which is in my case, just reverse the for the match it does is

aluno['ACERTOS_ATV2_D2'] >5.5 & aluno['IDADE'] >24.5 & aluno['**PROVA1_D2'] != 'P' & aluno['ASSISTIU_AULA_1_D2'] <0.5 & aluno['FEZ_FORUM_D2SIM'] >0.5**

It should be this

aluno['ACERTOS_ATV2_D2'] >5.5 & aluno['IDADE'] >24.5 & aluno['PROVA1_D2'] != 'P' & aluno['ASSISTIU_AULA_1_D2'] <0.5 & aluno['**FEZ_FORUM_D2SIM'] >0.5

Remembering that it's all in one line this text, it gets a little big and ends up breaking here

EDIT 1:

I thought it was all right with what I had done in my own answer, but I just found a little problem.

((PROVA1_D2|FEZ_FORUM_D2|REGIAO)(\w+))(.*?)\]\s\>\d\.\d

This regex is giving this match (asterisks)

aluno['*********REGIAOsudeste'] <0.5 & aluno['ANOCONCL_2G'] >2015.5 & aluno['IDADE'] <42.5 & aluno['ACERTOS_ATV3_D1'] <2.5 & aluno['BOLSA'] >0.2*************5 & aluno['PROVA1_D2P'] <0.5 & aluno['FEZ_FORUM_D2SIM'] <0.5

And in fact I wanted it to be of no match, since in the regex is the largest (>), not the least (<) symbol! The match would only happen with the minor symbol "<"

If you need, I've saved the situation here REGEX

    
asked by anonymous 29.12.2017 / 13:11

1 answer

1

Try to use it as well

((PROVA1_D2|FEZ_FORUM_D2|REGIAO)(\w+))\'\]\s(?!\<)\>\d{1}\.\d{1,2}

And the regex so

$2'] == '$3'
    
03.01.2018 / 13:45