Community
Participate
Working Groups
Build Identifier: WTP 3.2 The following statement contains a valid reg expression: searchStr.replace(/\n( |\t)*[/][/]/g,'//'); but the parser complains that the token "]" in the sequence "[/]" is unexpected. Reproducible: Always
I do not believe that is a valid regular expression statement. You close the expression here [/] and then keep going.
The expression was valid. The square brackets make "/" literal characters instead of the delimiter. Try the following sample code. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>test1</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <script type="text/javascript"> var searchStr = ">\n //<"; alert(searchStr); searchStr = searchStr.replace(/\n( |\t)*[/][/]/g,'//'); alert(searchStr); </script> </body> </html> Re-opening.
I also ran into this same issue with jQuery mobile 1.3.2 and jQuery mobile 1.4.0 alpha 2. Here is the expression causing the parser error: /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g
patch for source can be found here: https://github.com/jasonpet/webtools.jsdt.core/commit/aa736684c1471aa92fa1b3d68b8d426629f0cd8c patch for testcase can be found here: https://github.com/jasonpet/webtools.jsdt.tests/commit/7095990a72d0236cbcd1e8eb9d560d935cdc4a93
Give a brief technical overview. Who has reviewed this fix? - Syntax errors are thrown if the parser encounters the regular expression delimiter (/) within a character class ([...]). Characters should be treated as literal characters within the brackets. - This has been reviewed by the project lead. How has the fix been tested? - I have manually tested this and created new JUnits. Entire JUnit suite has been run. Is there a test case attached to the bugzilla record? Has a JUnit Test been added? - Yes, JUnits have been added What is the risk associated with this fix? - Minimal to no risk
looks good.. thanks
Delivered to 3.5.1 and master.