how can pass this regular expression in C# ?about"[]" mean - regular-language

I have the following regular expression:
^[A-Z&&[^EIOSTUYZ]][X|0-9&&[^4-6]][A-F[NWX]].?.?$
I don't how can pass this regular expression. I trid AW0AW,AXFX,3D0E, but all can't pass it.

Related

What does this syntactically mean in groovy?

When I do this in groovy shell (2.5.8):
groovy:000> println("s":"s")
[s:s]
===> null
Why did my print statement print a Map (if that's the case)?
The syntax println("s":"s") is an example of passing Named parameters, which are interpreted as a Map.
Like constructors, normal methods can also be called with named parameters. To support this notation, a convention is used where the first argument to the method is a Map.
So you have a parameter named s with a value that is also s and Groovy puts them into a Map for you, per the documentation linked above. You could add additional named parameters to the method call, which will also be added to the Map. This syntax is valid for any method that accepts a Map as its first argument. In the case of println, it accepts Object, and since Map is an Object, named parameters can be passed to this method.
What you see is an omission of square brackets in Map literal in Groovy.
The call can be rewritten as:
println( [ "aa":"bb" ] ) // all brackets in place
println "a":"bb" // no brackets at all
println a:"bb" // a variant, where the left part of : is treated as key in Map Literal

Using regex and its flags with .eq() function in python to ignore case

I've checked the docs (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.eq.html)
I'm thinking something like below where I can use and re.I to ingnore case or use any other flag for that matter.
df.column.eq('Male').sum()
You can use the Series.str.contains function with case=False argument, ^Male$ as regex pattern and the regex=True argument:
df['column'].str.contains('^Male$', case=False, regex=True).sum()
See the Series.str.contains documentation.
Also, see What do ^ and $ mean in a regular expression?

How to test if a string variable in Robot Framework is empty?

How to test if a string variable in Robot Framework is empty?
My first naïve attempt looked like this:
Run Keyword If ${myVar}!=${EMPTY}
but it failed:
Evaluating expression '!=' failed: SyntaxError: unexpected EOF while parsing (, line 1)
I then found this issue at Github but it didn't suggest a solution, just that the error message was unclear. An alternative solution was presented here:
${length}= Get Length ${Portfolio_ste}
Run Keyword If ${length} Go To Edit Portfolio
but is this really the best practice?
(The context is that I use a variable argument list and if a certain variable contains a value something should be done, otherwise just ignore it)
The expression needs to be a valid python expression after variable substitution. Assuming for the moment that myVar might be something like the number 42, your expression would end up looking like this after substitution:
Run Keyword if 42!=
When comparing against the empty string you need to add quotes to guarantee that the expression is a proper python expression after substitution. For example:
Run Keyword If "${myVar}"!="${EMPTY}"
Try Get Variable Value. It solved my problem.

how to get "leftover arguments" in optparse-applicative?

I am trying to use optparse-applicative.
How can I access arguments that are not options?
(From prog --foo --bar=42 baz, I want to get ["baz"])
All the the "high level" functions https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Extra.html
return a where I want (a,[String]).
There is some low-level function https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Common.html#v:runParser but I cannot call it directly because of its type. And indeed I do want to re-use all the plumbing that is in https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/src/Options-Applicative-Extra.html#execParser .
Positional arguments are part of the parser specification. They are not returned separately by the function that runs the parser. The functions argument and strArgument can be used to add a parser for a positional argument to the specification.

Assigning a mathematical string expression to double variable

I have a mathematical expression in string form like:
string strExpression = "10+100+Math.Sin(90)";
I want to simply assign this expression (at run time) to a float variable (say result), so that it becomes the following code statement:
float result = 10+100+Math.Sin(90);
How can I do this?
You have to compile the expression within a syntactically correct code block. See http://devreminder.wordpress.com/net/net-framework-fundamentals/c-dynamic-math-expression-evaluation/ as an example.
Edit: Or alternatively write your own expression parser if the expression is going to be VERY simple (I wouldn't recommend this though)
You could use CS-Script to dynamically make a class with a method that you can run, if you don't want to write your own parser but rather use C# which you allready know..

Resources