samedi 27 juin 2015

how to adjust javascript regexpression

I need to adjust a regex I am using for a file name. currently the file is structured 02-2015 VRF WE32.pdf the regex splits up the string into 3 pieces by the spaces. This works fine. the result is

02-2015
VRF
WE32

But now i need to split the string into 4 pieces. the 4th being the digits in the 'WE32'. so it needs to look like this

02-2015
VRF
WE
32

Here is what I am using, including some screenshots

var matchesPip = file.name.match(/^\d+\D\d+\s*(\S*\s*)(\S*)/i);
var matchesLoc = file.name.match(/^\d+\D\d+\s*?(\S*)\s*(\S*?)\./i);
var matchesLocCode = file.name.match(NEED HELP HERE);
    $scope.pip = $scope.pipeLookup[matchesPip[1]];
    $scope.loc = $scope.locationLookup[matchesLoc[2]];
    $scope.locCode = $scope.locationCodeLookup[matchesLocCode[3]];

pic1 pic2 pic3

Aucun commentaire:

Enregistrer un commentaire