2012-04-10 15 views
10

हमलावर लाइनकॉफ़ीस्क्रिप्ट: "str" ​​.replace (//g, "") क्यों coffeescript संकलन त्रुटि देता है?

"str".replace(/ /g, "") 

देता

Error: In orders.js.erb.coffee, Parse error on line 463: Unexpected 'MATH' 
    at Object.parseError (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:466:11) 
    at Object.parse (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:542:22) 
    at Object.compile (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:38:22) 
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:149:33 
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:115:19 
    at [object Object].<anonymous> (fs.js:107:5) 
    at [object Object].emit (events.js:61:17) 
    at afterRead (fs.js:878:12) 
    at wrapper (fs.js:245:17) 

इस coffeescript संकलक में एक बग है या मैं कुछ याद आ रही है?

उत्तर

28

Escape the first whitespace inside of the regexp

"str".replace(/\ /g, "") 

ठीक संकलित करता है।

+2

यह दुख की बात है कि कॉफ़ीस्क्रिप्ट दस्तावेज़ में नियमित अभिव्यक्तियों में रिक्त स्थान से बचने की आवश्यकता के बारे में कुछ भी नहीं है। – neuronaut

संबंधित मुद्दे