Regular expression coma search

1

I'm trying to create a regular expression that captures every line ej

an expression to find the first comma another that looks for the second comma and so on.

Santa Elena.- FOJAS 8148 NUMERO 11796 del año 2016, a FOJAS 8148 NUMERO 11797 del año 2016, a FOJAS 8149 NUMERO 11798 del año 2016, a FOJAS 8150 NUMERO 11799 del año 2016, a FOJAS 8151 NUMERO 11800 del año 2016, a FOJAS 8152 NUMERO 11801 del año 2016, y a FOJAS 8153 NUMERO 11802 del año 2016.- Lo expuesto consta en la escritura

  

. * (? = (a))

was using that expression

    
asked by Alvarows 02.08.2018 в 22:40
source

1 answer

1

You could try with [^,]+

The implementation will depend on the programming language you use. For example in javascript you could do it like this:

var re = /[^,]+/g;
var s = 'Santa Elena.- FOJAS 8148 NUMERO 11796 del año 2016, a FOJAS 8148 NUMERO 11797 del año 2016, a FOJAS 8149 NUMERO 11798 del año 2016, a FOJAS 8150 NUMERO 11799 del año 2016, a FOJAS 8151 NUMERO 11800 del año 2016, a FOJAS 8152 NUMERO 11801 del año 2016, y a FOJAS 8153 NUMERO 11802 del año 2016.- Lo expuesto consta en la escritura';
var m;

while (m = re.exec(s)) {
  alert(m);
}

Even more elegant would be to divide by commas. Virtually any programming language offers a method / function split or similar.

For example, in js:

var s = 'Santa Elena.- FOJAS 8148 NUMERO 11796 del año 2016, a FOJAS 8148 NUMERO 11797 del año 2016, a FOJAS 8149 NUMERO 11798 del año 2016, a FOJAS 8150 NUMERO 11799 del año 2016, a FOJAS 8151 NUMERO 11800 del año 2016, a FOJAS 8152 NUMERO 11801 del año 2016, y a FOJAS 8153 NUMERO 11802 del año 2016.- Lo expuesto consta en la escritura';
s.split(',').forEach(function(a){
  alert(a)
});
    
answered by 03.08.2018 / 13:51
source