Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
/ glob Public archive
forked from lindenbaum/glob

A library application to work with glob patterns.

License

Notifications You must be signed in to change notification settings

bors-ng/glob

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Old Build Status (TRAVIS)

glob

A library application to work with glob patterns. Now also available on hex.pm.

Syntax

This implementation provides the same glob pattern facilities as bash (partly from Wikipedia):

  • ?: Match exactly one unknown character.
  • *: Match any number of unknown characters from the position in which it appears to the end of the subject also match any number of unknown characters (regardless of the position where it appears, including at the start and/or multiple times.
  • [characters]: Match a character as part of a group of characters.
  • [!characters]: Match any character but the ones specified.
  • [character-charcter]: Match a character as part of a character range.
  • [!character-charcter]: Match any character but the range specified.

The underlying implementation utilizes the re module which means that a given glob pattern will be converted into a regular expression. For convenience this module features an API that is quite similar to the re module. Although, the shorthand glob:matches/1 enables a more intuitive and simple experience.

As glob relies on re it offers support for Unicode input. However, this support comes with the same restrictions known from re.

Example

Simple matches:

    false = glob:matches("Hello World", "Hello"),
    true = glob:matches("Hello World", "*"),
    true = glob:matches("Hello World", "Hello*Wo?l[d]"),

Match unicode input for expression/pattern and subject:

    {ok, MP} = glob:compile(<<"*ä?ö"/utf8>>, true),
    true = glob:matches("äüö", MP),

About

A library application to work with glob patterns.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 100.0%