How to use conditionals when replacing in Notepad++ via regex

The syntax in the conditional replacement is (?{GROUP_MATCHED?}REPLACEMENT_IF_YES:REPLACEMENT_IF_NO) The { and } are necessary to avoid ambiguity when you deal with groups higher than 9 and with named capture groups. Since Notepad++ uses Boost-Extended Format String Syntax, see this Boost documentation: The character ? begins a conditional expression, the general form is: ?Ntrue-expression:false-expression where N … Read more

#ifdef #ifndef in Java

private static final boolean enableFast = false; // … if (enableFast) { // This is removed at compile time } Conditionals like that shown above are evaluated at compile time. If instead you use this private static final boolean enableFast = “true”.equals(System.getProperty(“fast”)); Then any conditions dependent on enableFast will be evaluated by the JIT compiler. … Read more

What is “x && foo()”?

Both AND and OR operators can shortcut. So && only tries the second expression if the first is true (truth-like, more specifically). The fact that the second operation does stuff (whatever the contents of foo() does) doesn’t matter because it’s not executed unless that first expression evaluates to something truthy. If it is truthy, it … Read more

MySQL Conditional Insert

If your DBMS does not impose limitations on which table you select from when you execute an insert, try: INSERT INTO x_table(instance, user, item) SELECT 919191, 123, 456 FROM dual WHERE NOT EXISTS (SELECT * FROM x_table WHERE user = 123 AND item = 456) In this, dual is a table with one row only … Read more

Python 2: Conditional statement behaviour of lists with greater/smaller [duplicate]

So you are using Python2, where you can compare between list and strings and numbers. This helps to sort them out. Python2 [0]>1 => True However since Python3 this has been removed. Python3 [0]>1 Traceback (most recent call last): File “python”, line 1, in <module> TypeError: unorderable types: list() > int() Hope that explains, why … Read more