TooTallNate / pcre-to-regexp

Converts PCRE regexp strings to JavaScript RegExp instances
MIT License
22 stars 6 forks source link

getting error when using (?!strToExclude) #1

Open 534N opened 10 years ago

534N commented 10 years ago

So as stated in the title, I got the following error:

SyntaxError: Invalid flags supplied to RegExp constructor '?!ENET-RX|ENET-TX)\S+)_LBR_'
    at new RegExp (<anonymous>)
    at PCRE (/Users/xiaofanyang/workspace/booking/node_modules/pcre-to-regexp/index.js:97:16)

when trying to exec that regex...

TooTallNate commented 10 years ago

Can you show me the source PCRE regexp you're trying to use?

534N commented 10 years ago

Ya... actually, I am hitting another problem, it reports something different this time (after I adjusted my regexp)

regex: \d+\s+\S+\s+\S\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(?<errCount>\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d[\s|\S]\d\s+\S\s+\S\s+(?<name>(?!ENET-\S+)\S+)_LBR
string: IOCTRL 0 (BASECARD)_LBR_    Ch/Dr P Last Curr Head Tail   Num  Max  Pend    Packets Error   Big Dscrd KBusy NAddr IgIrq    DefW     R D Name_LBR_     0 Rx N  758   59  759   59   700 1023     0     189499     0     0     0     0     0 19145     0 0     Y N IN-ICC-REQ-40_LBR_     1 Rx N  520  845  521  845   700 1023     0     335693     0     0     0     0     0  9212     0 0     Y N IN-ICC-RESP-41_LBR_    

The error reports is:

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot read property '1' of null
    at /Users/xiaofanyang/workspace/booking/node_modules/pcre-to-regexp/index.js:75:58
    at replaceCaptureGroups (/Users/xiaofanyang/workspace/booking/node_modules/pcre-to-regexp/index.js:143:28)
    at PCRE (/Users/xiaofanyang/workspace/booking/node_modules/pcre-to-regexp/index.js:67:13)
534N commented 10 years ago

Hi, have you had a chance to see what caused this problem?

Well, basically, I looked at your script and it looks like it is failing the negative assertion:

GROUP>>>>>>>>>(?<name>(?!ENET-\S+)\S+)

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot read property '1' of null
    at /Users/xiaofanyang/workspace/booking/node_modules/pcre-to-regexp/index.js:76:58

Any chance you can fix this?