10 Java Regular Expression Examples You Should Know

By mkyong – November 18, 2009

Regular expression is an art of the programing, it’s hard to debug , learn and understand, but the powerful features are still attract many developers to code regular expression. Let’s explore the following 10 practical regular expression ~ enjoy 🙂

1. Username Regular Expression Pattern

^[az09_]{3,15}$

^ # Start of the line

[az09_] # Match characters and symbols in the list, a-z, 0-9 , underscore , hyphen

{3,15} # Length at least 3 characters and maximum length of 15

$ # End of the line Continue reading “10 Java Regular Expression Examples You Should Know”

Make Your Program Slower With Threads

How much do context switches matter?

By Marc Brooker

Years ago, while taking a numerical methods course, I wrote some code to calculate the expected number of shared birthdays in a group. The code is very simple: each attempt constructs a vector of N birthdays, then counts the duplicates. The outer loop runs millions of attempts, and calculates the mean number of shared birthdays across all the samples. It’s little more than a tight loop around a pseudo-random number generator. Continue reading “Make Your Program Slower With Threads”