Description Usage Arguments Warning See Also Examples
Build a regular expression to fit chosen parameters
1 2 | model_to_regex(model = "*", allow = letters, ban = character(0),
type = "usual")
|
model |
pattern that a word should match. Consists of letters and
unknown characters specifications. Dot |
allow |
characters allowed to fill gaps in a word. Can be listed in a
single string or in a vector. By default is set to |
ban |
characters not allowed to fill gaps in a word. |
type |
can be
|
If type = "scrabble"
or "anagram"
, output
regex will contain perl-like syntax. So, to use it in grep
or
gsub
for example, set perl
parameter to TRUE
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Regular expression to match all the 5-letter words starting with "c".
model_to_regex("c.{4}")
## Disallow "a" and "b".
model_to_regex("c.{4}", ban = "ab")
## Allow only "a" and "b" to fill the gap.
model_to_regex("c.{4}", allow = "ab")
## Allow "a", "b", and "c", but then ban "c" (result is the same as the previous example)
model_to_regex("c.{4}", allow = "abc", ban = "c")
## Regex to match all words that start with "p" and end with "zed".
model_to_regex("p*zed")
## Regex to match all the words that can be constructed of the word "thing".
model_to_regex(allow = "thing", type = "scrabble")
## Get at lest 4-letter words.
model_to_regex(".{4,}", allow = "thing", type = "scrabble")
## Regex to match anagrams of the word "thing"
model_to_regex(allow = "thing", type = "anagram")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.