Ruby Regex error - ruby

My regex:
https?://[\w-]+(?:\.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?
In Ruby, I get the following error:
unmatched close parenthesis:/https?://[\w-]+(?:\.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?/'
How can I fix this?

I don't know how I could be clearer than the error message. Your regex has an unmatched close parenthesis.
https?://[\w-]+(?:.[\w-]+)+(?:/[\w-]+)*(?:[./%?=&#-]\w+)+)?
Notice how there's 3 ( and 4 )
Further reading in regexes http://www.regular-expressions.info/tutorial.html
Specifically, you may want to check out the character information http://www.regular-expressions.info/characters.html

There seems to be one "close parenthesis" too much.
as it also says in the error message ;)

Related

Are there ways to modify Rstudio's Console behavior when adding missing quotes

I've search both SO and Rstudio's community pages and failed to find aquestion, much less and answer to this annoyance I have experienced with Rstudio. (The Rstudio help pages won't let me post a second question within 12 hours of my first, which was explained as a bug.)
If I type:
(test)
... and then realize that test should be quoted, then putting the cursor at the end to test and entering a double-quote will give me two double-quotes "". It will not do this if I first enter a quote between ( and t and then it will also not give me doubling of the double-quote character at the end of `test. Why should it matter whether I first correct my error at the end of the symbol or at the beginning? Is there anything I can do to modify this quirk> It seems that a syntax aware console editor out to be able to tell when a doubling of quotes does not make sense. It's obviously making that "decision" when the quotes are entered between an open-paren and a character. Why not suppress the unhelpful behavior when it is between a character and a close-paren?

What means SPSS syntax Error n° 10933 and how to resolve it?

I am currently running an aggregate function and I get :
Error n° 10933 in column 1. Text: DATASET
The definition of a new variable on the AGGREGATE command must be
terminated by a slash.
This command not executed.
I want to have the fertility ratio (Child-Woman ratio) from a 1911 census. Here is my syntax (I added the spaces here):
Screen shot of the syntax here
I just don't understand why it cannot go through and adding slashes does not help either.
I seems to be a very banal error.
Does anyone have any advice ?
Thank you !
SPSS commands should be ended with periods. Your syntax treats the DATASET ACTIVATE as a continuation of the AGGREGATE command, and the parser thinks "DATASET" is a new variable. Put a period after the closed parentheses to finish the command.

Prolog syntax error: operator expected

I was studying the Prolog, and met with the "syntax error: operator expected" for the following code:
odd_list(X,Y):-process_list(X,Y,1).
process_list(X,[N1|Y],N):-N1 is 2*N-1,N1 < X,N2 is N+1,process_list(X,Y,N2).
process_list(X,[],N):-2*N-1>=X.
That's all the code I wrote. What's the problem? I found some solutions saying that there are unexpected white spaces in the functors or arguments, but I think I do not include any white space in the above-mentioned places.
Thank you all for helping me!!!
Remark: I find that when I name the source code as "Test1.pl", I get this error. But when I name it as "test1.pl", there is no error. Does it mean that the file name cannot start with an upper case letter?
I found the reason for this problem. I used the file name 'Test1'. But Prolog does not support upper case letter in the file name. I modified the file name to 'test1' and it works now.

What does "(...) interpreted as grouped expression" mean?

I'm using a Ruby linter in Atom and for some lines it gives the following warning:
(...) interpreted as grouped expression
An example of a line that get's this warning is this:
elsif not (params[:vacancy].nil? or params[:vacancy]['company_id'].nil? or params[:vacancy]['company_id'] == "0" )
How should that line be improved to make the warning go away?
The warning is
(...) interpreted as grouped expression
And it means exactly what it says: in Ruby, parentheses can be used for three purposes, expression grouping, parameter lists and argument lists. This warning is emitted when Ruby thinks that you want an argument list but wrote a grouped expression instead. The most common cause is whitespace between the name of the message and the argument list in a message send like this:
foo.bar (1, 2)
This will be interpreted not as an argument list for the message send, but rather a grouped expression, which, in this particular case, is a SyntaxError.
In your particular case, the warning seems to be a false positive.
Try to Remove the space between not and the parenthesis
The warning I get is from from MRI Ruby itself (with options -wc), and I think you have a typo in there. The message I get doesn't have the word "grounded" but "grouped".
Parenthesis in Ruby can be used for one of two things, to group expressions or to mark the argument list of a function or method.
What that error message is saying is that of these two options, Ruby is treating it like an expression. Note that it in Ruby is possible for you to define a method called "not".
And In this particular case it doesn't matter which way Ruby interprets the parenthesis.
One way to get rid of the message is to remove the space between "not (". If you think this is screwy, I agree with you.

MicroStrategy ApplySimple Syntax

i'm trying to use the ApplySimple function in order to define a Metric in MicroStratey. My gloal is to cast a fact column to double value.
My current metric definition is:
ApplySimple("TO_DOUBLE(#0)", MYFACT)
The syntax check reports a wrong expression and indicates the error by marking the comma.
I tried to remove the MYFACT parameter including comma, but the syntax check fails as well, indicating the error on right parenthesis.
ApplySimple("TO_DOUBLE(MYFACT)")
Any suggentions on how to correct the syntax?
Thank you very much!
Kind regards
Okay, just got the problem. You have to use ";" insted of "," after the expression.

Resources