Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex double output #5652

Closed
rurigk opened this issue Mar 11, 2016 · 2 comments
Closed

Regex double output #5652

rurigk opened this issue Mar 11, 2016 · 2 comments
Labels
invalid Issues and PRs that are invalid. v8 engine Issues and PRs related to the V8 dependency.

Comments

@rurigk
Copy link

rurigk commented Mar 11, 2016

Input :

format code  extension  resolution note
243       webm     640x360  DASH video  190k , vp9, 30fps, vid
247       webm     1280x720   DASH video  509k , vp9, 30fps, v
136       mp4       1280x720   DASH video  958k , avc1.4d401f, 30
17         3gp      176x144 small , mp4v.20.3,  mp4a.40.2@ 24k
36         3gp      320x180 small , mp4v.20.3,  mp4a.40.2
5           flv     426x240 small , h263, mp3  @ 64k
43         webm    640x360  medium , vp8.0,  vorbis@128k
18         mp4      640x360 medium , avc1.42001E,  mp4a.
22         mp4      1280x720   hd720 , avc1.64001F,  mp4a.4

Code:

function getQualitys(d){
    var re = /^([0-9]{1,2})\s+(mp4)\s+([0-9x]+)\s+(.+)$/gm;
    var m;
    var gma = [];
    while ((m = re.exec(d)) !== null) {
        if (m.index === re.lastIndex) {
            re.lastIndex++;
        }
        gma[gma.length] = [m[1],m[2],m[3],m[4]];
    }
    return gma;
}

Node js Output:

[
  [
    '18',
    'mp4',
    '640x360',
    'medium , avc1.42001E,  mp4a.40.2@ 96k'
  ],
  [
      '22',
    'mp4',
    '1280x720',
    'hd720 , avc1.64001F,  mp4a.40.2@192k (best)'
  ],
  [
    '18',
    'mp4',
    '640x360',
    'medium , avc1.42001E,  mp4a.40.2@ 96k'
  ],
  [
      '22',
    'mp4',
    '1280x720',
    'hd720 , avc1.64001F,  mp4a.40.2@192k (best)'
  ]
]

Firefox Output :

[
  [
    '18',
    'mp4',
    '640x360',
    'medium , avc1.42001E,  mp4a.40.2@ 96k'
  ],
  [
      '22',
    'mp4',
    '1280x720',
    'hd720 , avc1.64001F,  mp4a.40.2@192k (best)'
  ]
]

Version : v5.7.1
Linux rurigk 3.19.0-49-generic #55-Ubuntu SMP Fri Jan 22 02:10:24 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

@mscdex
Copy link
Contributor

mscdex commented Mar 11, 2016

I tested with node 5.7.1 and the included input and code works just fine for me:

var input = `
format code  extension  resolution note
243       webm     640x360  DASH video  190k , vp9, 30fps, vid
247       webm     1280x720   DASH video  509k , vp9, 30fps, v
136       mp4       1280x720   DASH video  958k , avc1.4d401f, 30
17         3gp      176x144 small , mp4v.20.3,  mp4a.40.2@ 24k
36         3gp      320x180 small , mp4v.20.3,  mp4a.40.2
5           flv     426x240 small , h263, mp3  @ 64k
43         webm    640x360  medium , vp8.0,  vorbis@128k
18         mp4      640x360 medium , avc1.42001E,  mp4a.
22         mp4      1280x720   hd720 , avc1.64001F,  mp4a.4
`;

function getQualitys(d){
    var re = /^([0-9]{1,2})\s+(mp4)\s+([0-9x]+)\s+(.+)$/gm;
    var m;
    var gma = [];
    while ((m = re.exec(d)) !== null) {
        if (m.index === re.lastIndex) {
            re.lastIndex++;
        }
        gma[gma.length] = [m[1],m[2],m[3],m[4]];
    }
    return gma;
}

console.dir(getQualitys(input));

Output:

[ [ '18', 'mp4', '640x360', 'medium , avc1.42001E,  mp4a.' ],
  [ '22', 'mp4', '1280x720', 'hd720 , avc1.64001F,  mp4a.4' ] ]

@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Mar 11, 2016
@rurigk
Copy link
Author

rurigk commented Mar 11, 2016

Sorry, I discovered my problem the error is in the module that used
I have already changed the module and everything has been corrected

@rurigk rurigk closed this as completed Mar 11, 2016
@mscdex mscdex added the invalid Issues and PRs that are invalid. label Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Issues and PRs that are invalid. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

2 participants