REGEX / NOTES</>↗Regex05 Nov 2010
The reluctant quantifiers start the matcher at the beginning of the input string, then reluctantly eat one character at a time looking for a match. The last thing they try is the entire input string. package org.kodejava.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ReluctantQuantifierDemo { public static void main(String[] args) { String[] expressions = {"x??", […]
REGEX / NOTES</>↗Regex05 Nov 2010
The possessive quantifiers always eat the entire input string, trying once (and only once) for a match. Unlike the greedy quantifiers, possessive quantifiers never back off, even if doing so would allow the overall match to succeed. package org.kodejava.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PossessiveQuantifierDemo { public static void main(String[] args) { String[] regexs […]
REGEX / NOTES</>↗Regex05 Nov 2010
It’s also possible to enable various flags using embedded flag expressions. Embedded flag expressions are an alternative to the two-argument version of compile, and are specified in the regular expression itself. The example below is use (?i) flag expression to enable case-insensitive matching. Another flag expressions are listed below: (?x), equivalent with Pattern.COMMENTS (?m), equivalent […]
CORE API / NOTES</>↗Core API05 Nov 2010
You can pause a current thread for a number of milliseconds by using the sleep() method of the Thread class. While the current thread is sleeping, it will allow other threads to execute. package org.kodejava.lang; public class ThreadSleepDemo implements Runnable { public static void main(String[] args) { Thread thread = new Thread(new ThreadSleepDemo()); thread.start(); } […]
CORE API / NOTES</>↗Core API05 Nov 2010
To make a thread begin its execution, call the start() method on a Thread or Runnable instance. Then the Java Virtual Machine will calls the run method of this thread. The snippet below is showing how to create a thread by implementing the Runnable interface. package org.kodejava.lang; public class ThreadRun implements Runnable { public static […]
REGEX / NOTES</>↗Regex03 Nov 2010
A quantifier following a subsequence of a pattern determines the possibilities for how that subsequence of a pattern can repeat. Quantifiers allow you to specify the number of occurrences to match against. Quantifiers X? : X, once or not at all X* : X, zero or more times X+ : X, one or more times […]