OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Unmatched parenthesis that is not supposed to be a literal [duplicate]

  • Thread starter Thread starter Jill Grant
  • Start date Start date
J

Jill Grant

Guest
I am making a stylelint configuration file (uses javascript). We use strings for regular expressions. I have

Code:
[“^(\[a-z\]\[a-zA-Z0-9\]+)|(abc-+(.+))$”,{“message":"(selector) =\> Expected class selector \"${selector}\" to be lowerCamelCase or begin with abc"}]

as a parameter of a rule. It is supposed to make sure a variable is in lowerCamelCase or that it starts with abc- and continues on after that.

My concern is with the matching part. It works in regexr (after removing beginning \. that is actually accounted for with ^ in the javascript code) (test cases reflect usage)

regexr parameter is successful at testing use cases
I also tested regexr with removing the ^ and results were the same. I did have to use many grouping parantheses and I think this is where the problems arise in javascript.

The error I receive is

stderr: List(SyntaxError: Invalid regular expression: /[“^([a-z][a-zA-Z0-9]+)|(abc-+(.+))$”,{“message":"(selector) => Expected class selector "${selector}" to be lowerCamelCase or begin with abc"}]/: Unmatched ')', at new RegExp (<anonymous>)

I see a lot about unmatched paranthesis errors coming up when they are supposed to be string literals. My problem is that it's NOT supposed to be a string literal, just a grouping tool. I don't want to escape it, and I can't remove any.

I already removed a set of parantheses around the whole thing (which I was already iffy about, since that $ end character needs to apply to both sides of the "or" set) when the unmatched paranthesis error first came up. I know that there are no frivolous parantheses here.

<p>I am making a stylelint configuration file (uses javascript). We use strings for regular expressions.
I have</p>
<pre><code>[“^(\[a-z\]\[a-zA-Z0-9\]+)|(abc-+(.+))$”,{“message":"(selector) =\> Expected class selector \"${selector}\" to be lowerCamelCase or begin with abc"}]
</code></pre>
<p>as a parameter of a rule. It is supposed to make sure a variable is in lowerCamelCase or that it starts with <code>abc-</code> and continues on after that.</p>
<p>My concern is with the matching part. It works in regexr (after removing beginning <code>\</code>. that is actually accounted for with <code>^</code> in the javascript code) (test cases reflect usage)</p>
<p><img src="https://i.sstatic.net/fIk21c6t.png" alt="regexr parameter is successful at testing use cases" />
I also tested regexr with removing the <code>^</code> and results were the same. I did have to use many grouping parantheses and I think this is where the problems arise in javascript.</p>
<p>The error I receive is</p>
<blockquote>
<p>stderr: List(SyntaxError: Invalid regular expression: /[“^([a-z][a-zA-Z0-9]+)|(abc-+(.+))$”,{“message":"(selector) => Expected class selector "${selector}" to be lowerCamelCase or begin with abc"}]/: Unmatched ')', at new RegExp (<anonymous>)</p>
</blockquote>
<p>I see a lot about unmatched paranthesis errors coming up when they are supposed to be string literals. My problem is that it's NOT supposed to be a string literal, just a grouping tool. I don't want to escape it, and I can't remove any.</p>
<p>I already removed a set of parantheses around the whole thing (which I was already iffy about, since that <code>$</code> end character needs to apply to both sides of the "or" set) when the unmatched paranthesis error first came up. I know that there are no frivolous parantheses here.</p>
 

Latest posts

Top