Tutorial by Examples

You should remember that regex was designed for matching a date (or not). Saying that a date is valid is a much more complicated struggle, since it will require a lot of exception handling (see leap year conditions). Let's start by matching the month (1 - 12) with an optional leading 0: 0?[1-9]|1[...
Matching an email address within a string is a hard task, because the specification defining it, the RFC2822, is complex making it hard to implement as a regex. For more details why it is not a good idea to match an email with a regex, please refer to the antipattern example when not to use a ...
Here's how to match a prefix code (a + or (00), then a number from 1 to 1939, with an optional space): This doesn't look for a valid prefix but something that might be a prefix. See the full list of prefixes (?:00|\+)?[0-9]{4} Then, as the entire phone number length is, at most, 15, we can look...
A simple example: CL-USER> (defun make-apply-twice (fun) "return a new function that applies twice the function`fun' to its argument" (lambda (x) (funcall fun (funcall fun x)))) MAKE-APPLY-TWICE CL-USER> (funcall (make-apply-twice #'1+) 3) 5 ...
Sometimes we need preserve whole model and transfer it across actions or even controllers. Storing model at session good solution for this type of requirements. If we combine this with powerful model binding features of MVC we get elegant way of doing so. We can create generic session based model bi...
Read the accelerometer Sensor with precision. This example allocates memory: void Update() { //Get Precise Accelerometer values Vector3 accelValue = preciseAccelValue(); Debug.Log("PRECISE X: " + accelValue.x + " Y: " + accelValue.y + " Z: " + acc...
Given a String containing the name of a class, it's Class object can be accessed using Class.forName: Class clazz = null; try { clazz = Class.forName("java.lang.Integer"); } catch (ClassNotFoundException ex) { throw new IllegalStateException(ex); } Java SE 1.2 It can be s...
Angular 2 offers two different types of pipes - stateless and stateful. Pipes are stateless by default. However, we can implement stateful pipes by setting the pure property to false. As you can see in the parameter section, you can specify a name and declare whether the pipe should be pure or not, ...
NA is a logical type and a logical operator with an NA will return NA if the outcome is ambiguous. Below, NA OR TRUE evaluates to TRUE because at least one side evaluates to TRUE, however NA OR FALSE returns NA because we do not know whether NA would have been TRUE or FALSE NA | TRUE # [1] TRUE ...
int n = 0; while (n < 5) { Console.WriteLine(n); n++; } Output: 0 1 2 3 4 IEnumerators can be iterated with a while loop: // Call a custom method that takes a count, and returns an IEnumerator for a list // of strings with the names of theh largest city metro areas. ...
A For Loop is great for doing things a certain amount of time. It's like a While Loop but the increment is included with the condition. A For Loop is set up like this: for (Initialization; Condition; Increment) { // Code } Initialization - Makes a new local variable that can only be us...
It is similar to a while loop, except that it tests the condition at the end of the loop body. The Do - While loop executes the loop once irrespective of whether the condition is true or not. int[] numbers = new int[] { 6, 7, 8, 10 }; // Sum values from the array until we get a total that's ...
// Print the multiplication table up to 5s for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 5; j++) { int product = i * j; Console.WriteLine("{0} times {1} is {2}", i, j, product); } }
You can reload the current state using the $state.reload method from your controller $state.reload() This is a shorthand for (code taken from the official docs) $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false }); Running a reload on your ...
$state.go is shorthand method to $state.transitionTo $state.go(toState [, toParams] [, options]) This method automatically sets your options to { location: true, inherit: true, relative: $state.$current, notify: true } (unless you override them) and allows you to transition with less code. Ex...
Constants in Go may be typed or untyped. For instance, given the following string literal: "bar" one might say that the type of the literal is string, however, this is not semantically correct. Instead, literals are Untyped string constants. It is a string (more correctly, its default ...
If you have only just popped it and the terminal is still open, you will still have the hash value printed by git stash pop on screen: $ git stash pop [...] Dropped refs/stash@{0} (2ca03e22256be97f9e40f08e6d6773c7d41dbfd1) (Note that git stash drop also produces the same line.) Otherwise, you...
Microsoft Access is one of the Microsoft Office suite of programs. However, it is only available in some packages of MS Office. If you wish to obtain Access, please make sure to carefully examine the box or download specifications for each version of Microsoft Office. MS Access is only available fo...
Sometimes it makes sense to nest view's or routes within one another. For example on the dashboard you want several sub views, similar to tabs but implemented via the routing system, to show the users' projects, contacts, messages ets. In order to support such scenarios the router allows us to defin...
Analysis of Variance (aov) is used to determine if the means of two or more groups differ significantly from each other. Responses are assumed to be independent of each other, Normally distributed (within each group), and the within-group variances are assumed equal. In order to complete the analys...

Page 479 of 1336