wildcard

Scala: How to handle wildcard characters when running external commands

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 12.17, “How to handle wildcard characters when running external commands.”

Problem

You want to use a Unix shell wildcard character, such as *, in an external command.

How to hide a class (or classes) with Scala import statements

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 7.4, “How to hide a class (or classes) with Scala import statements.”

Problem

You want to hide one or more classes while importing other members from the same package.

Solution

To hide a class during the import process, use the renaming syntax shown in Recipe 7.3, “Renaming Members on Import”, but point the class name to the _ wildcard character.

How to import multiple members in Scala (wildcard and curly braces syntax)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one the shorter recipes, Recipe 7.2, “How to import multiple members in Scala (wildcard and curly braces syntax).”

Problem

You want to import one or more members into the scope of your current program.

Solution

This is the syntax for importing one class:

import java.io.File

You can import multiple classes the Java way:

How to access the value of the default case in a Scala match expression

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one of the shorter recipes, Recipe 3.10, “How to access the value of the default case in a Scala match expression.”

Problem

You want to access the value of the default, “catch all” case when using a match expression, but you can’t access the value when you match it with the _ wildcard syntax.

Solution

Instead of using the _ wildcard character, assign a variable name to the default case:

Apache RedirectMatch wildcard examples

Apache Redirect 301 FAQ: How can I redirect many old web pages using the Apache Redirect or RedirectMatch syntax and wildcard patterns (regex patterns)?

I'm currently trying to fix a lot of URLs that I more or less intentionally broke when I deleted the old "directory" portion of this website. In short, after removing the directory, no URL at "/Dir" work any more, so I have thousands of broken URLs (technically "URIs") that look like this:

Java: How to list all files in a directory that match a filename extension

I just ran across this Java method I used to create a list of all files in a directory that match a specific filename pattern, or more specifically, matched the same filename extension.

The Java "list files in a directory" source code

First, here's the source code for this Java "list files" method. I'll follow this code with a brief description:

Perl - How to process every file in a directory that matches a pattern

Perl FAQ: "How can I process every file in a directory that matches a certain filename pattern?"

There are several ways to do this, but I normally use the glob function, because I can remember the syntax pretty easily.

Let's look at a couple of glob examples.

Using the glob operator

You can use the glob operator to get a list of all files in the current directory like this: