alphanumeric

Scala: How to match a regex pattern against an entire String

Scala regex FAQ: How can I match a regex pattern to an entire string in Scala?

This morning I needed to write a little Scala code to make sure a String completely matches a regex pattern. I started off by creating a Scala Regex instance, and then realized the Regex class doesn't have a simple method to determine whether a String completely matches a pattern.

Scala: How to create a list of alpha or alphanumeric characters

While looking for code on how to create a random string in Scala, I came across this article, which shows one approach for creating a random string. For my brain today, it also shows a nice way to create a list of alpha or alphanumeric characters.

For instance, to create a list of alphanumeric characters, use this approach:

PHP - strip all non alphanumeric characters from a string

A PHP function that strips a string of all characters other than alphanumeric characters:

function onlyAlphanumericAndSpaces($text) {
  # allow only alphanumeric
  return ereg_replace("[^A-Za-z0-9 ]", "", $text );
}