Tutorial by Examples

Given the flavors, the named capture group may looks like this: (?'name'X) (?<name>X) (?P<name>X) With X being the pattern you want to capture. Let's consider the following string: Once upon a time there was a pretty little girl... Once upon a time there was a unicorn with an h...
As you may (or not) know, you can reference a capture group with: $1 1 being the group number. In the same way, you can reference a named capture group with: ${name} \{name} g\{name} Let's take the preceding example and replace the matches with The hero of the story is a ${subject}. T...
A reference cycle (or retain cycle) is so named because it indicates a cycle in the object graph: Each arrow indicates one object retaining another (a strong reference). Unless the cycle is broken, the memory for these objects will never be freed. A retain cycle is created when two instances of ...
In a normal string, the backslash character is the escape character, which instructs the compiler to look at the next character(s) to determine the actual character in the string. (Full list of character escapes) In verbatim strings, there are no character escapes (except for "" which is ...
In functions taking callable as an argument, you can also put a string with PHP built-in function. It's common to use trim as array_map parameter to remove leading and trailing whitespace from all strings in the array. $arr = [' one ', 'two ', ' three']; var_dump(array_map('trim', $arr)); ...
To parse lots of parameters, the prefered way of doing this is using a while loop, a case statement, and shift. shift is used to pop the first parameter in the series, making what used to be $2, now be $1. This is useful for processing arguments one at a time. #!/bin/bash # Load the user define...
These behave in the same manner as nested subqueries but with a different syntax. WITH ReadyCars AS ( SELECT * FROM Cars WHERE Status = 'READY' ) SELECT ID, Model, TotalCost FROM ReadyCars ORDER BY TotalCost; IDModelTotalCost1Ford F-1502002Ford F-150230 Equivalent subquery syntax ...
WITH RECURSIVE ManagersOfJonathon AS ( -- start with this row SELECT * FROM Employees WHERE ID = 4 UNION ALL -- get manager(s) of all previously selected rows SELECT Employees.* FROM Employees JOIN ManagersOfJonathon ON Employees.ID = Manager...
Most databases do not have a native way of generating a series of numbers for ad-hoc use; however, common table expressions can be used with recursion to emulate that type of function. The following example generates a common table expression called Numbers with a column i which has a row for numbe...
WITH RECURSIVE ManagedByJames(Level, ID, FName, LName) AS ( -- start with this row SELECT 1, ID, FName, LName FROM Employees WHERE ID = 1 UNION ALL -- get employees that have any of the previously selected rows as manager SELECT ManagedByJames.Level + 1, ...
BuildConfigField Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build fla...
# Create the nodes # In a real world scenario we would use at least 3 managers to cover the fail of one manager. docker-machine create -d virtualbox manager docker-machine create -d virtualbox worker1 # Create the swarm # It is possible to define a port for the *advertise-addr* and *listen-ad...
MATLAB supports (and encourages) vectorized operations on vectors and matrices. For example, suppose we have A and B, two n-by-m matrices and we want C to be the element-wise product of the corresponding elements (i.e., C(i,j) = A(i,j)*B(i,j)). The un-vectorized way, using nested loops is as follo...
There is a collection in .Net used to manage values in a Queue that uses the FIFO (first-in first-out) concept. The basics of queues is the method Enqueue(T item) which is used to add elements in the queue and Dequeue() which is used to get the first element and remove it from the queue. The generic...
The ~ operator will flip all of the bits in the number. Since computers use signed number representations — most notably, the two's complement notation to encode negative binary numbers where negative numbers are written with a leading one (1) instead of a leading zero (0). This means that if you w...
public struct Vector { public int X; public int Y; public int Z; } public struct Point { public decimal x, y; public Point(decimal pointX, decimal pointY) { x = pointX; y = pointY; } } struct instance fields can be set via a p...
Assuming the following Person class: public class Person { public string Name { get; set; } public int Age { get; set; } } The following lambda: p => p.Age > 18 Can be passed as an argument to both methods: public void AsFunc(Func<Person, bool> func) public void AsE...
You can combine object initializers with constructors to initialize types if necessary. Take for example a class defined as such: public class Book { public string Title { get; set; } public string Author { get; set; } public Book(int id) { //do things } // the...
<input type="reset" value="Reset"> An input of type reset creates a button which, when clicked, resets all inputs in the form it is contained in to their default state. Text in an input field will be reset to blank or its default value (specified using the value attri...
length counts the occurences of elements a in a foldable structure t a. ghci> length [7, 2, 9] -- t ~ [] 3 ghci> length (Right 'a') -- t ~ Either e 1 -- 'Either e a' may contain zero or one 'a' ghci> length (Left "foo") -- t ~ Either String 0 ghci> length (3, True) ...

Page 96 of 1336