https://github.com/opusvl/string-substitute
Generate string with all combinations of a set of character substitutions applied.
https://github.com/opusvl/string-substitute
Last synced: about 1 year ago
JSON representation
Generate string with all combinations of a set of character substitutions applied.
- Host: GitHub
- URL: https://github.com/opusvl/string-substitute
- Owner: OpusVL
- Created: 2017-03-22T12:05:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-29T14:52:47.000Z (over 9 years ago)
- Last Synced: 2025-03-13T22:11:22.648Z (over 1 year ago)
- Language: Perl
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
String::Substitute - generate strings using different combinations of
subsitute characters
VERSION
version 0.007
SYNOPSIS
use String::Substitute qw(get_all_substitutes);
my @results = get_all_substitutes(
string => 'ABC',
substitutions => {
A => 'Aa',
B => 'Bb',
},
);
say for @results;
would print (with nondeterministic order):
ABC
aBC
AbC
abC
As a one-liner it might look like this:
perl -Ilib -MString::Substitute=get_all_substitutes -E 'say for get_all_substitutes(string => "ABC", substitutions => { A => "Aa", B => "Bb" })'
DESCRIPTION
This module is all about generating strings given an initial string and
a set of allowed character substitutions.
EXPORTS
get_all_substitutes
Return, as a list, all possible strings that can be generated by
applying different combinations of substitutions to the string passed
as the 'string' argument. See SYNOPSIS for an example.
The order in which the different candidates are returned is not
guaranteed.
Takes only keyword arguments:
string
The string you want to apply the substitutions on.
substitutions
A HASHREF mapping each substitutable character to a string of
different characters that it may be replaced with.
e.g. {A => "Aa", B => "Bb"} means that each occurrence of A will be
replaced with an 'A', or an 'a', in the returned substitutions.
SUPPORT
If you require assistance, support, or further development of this
software, please contact OpusVL using the details below:
Telephone: +44 (0)1788 298 410
Email: community@opusvl.com
Web: http://opusvl.com
AUTHOR
Nicholas Booker
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by OpusVL - www.opusvl.com.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.