[DOCS] Mention YAML single vs double quotes in regex docs (#719)
Improve regex plugin docs by mentioning difference between using single-quotes and double-quotes in YAML: https://ytdl-sub.readthedocs.io/en/latest/config.html#regex
This commit is contained in:
parent
0008bf3aca
commit
0b62cc13d0
1 changed files with 9 additions and 6 deletions
|
|
@ -124,10 +124,13 @@ class FromSourceVariablesRegex(StrictDictValidator):
|
||||||
class RegexOptions(OptionsDictValidator):
|
class RegexOptions(OptionsDictValidator):
|
||||||
r"""
|
r"""
|
||||||
Performs regex matching on an entry's source or override variables. Regex can be used to filter
|
Performs regex matching on an entry's source or override variables. Regex can be used to filter
|
||||||
entries from proceeding with download or capture groups to create new source variables. NOTE to
|
entries from proceeding with download or capture groups to create new source variables.
|
||||||
use backslashes anywhere in your regex, i.e. ``\d``, you must add another backslash escape. This
|
|
||||||
means ``\d`` should be written as ``\\d``. This is because YAML requires an escape for any
|
NOTE that YAML differentiates between single-quote (``'``) and double-quote (``"``), which can
|
||||||
backslash usage.
|
affect regex. Double-quote implies string literals, i.e. ``"\n"`` is the literal chars ``\n``,
|
||||||
|
whereas single-quote, ``'\n'`` gets evaluated to a new line. To escape ``\`` when using
|
||||||
|
single-quote, use ``\\``. This is necessary if you want your regex to be something like
|
||||||
|
``\d\n`` to match a number and adjacent new-line. It must be written as ``\\d\n``.
|
||||||
|
|
||||||
If you want to regex-search multiple source variables to create a logical OR effect, you can
|
If you want to regex-search multiple source variables to create a logical OR effect, you can
|
||||||
create an override variable that contains the concatenation of them, and search that with regex.
|
create an override variable that contains the concatenation of them, and search that with regex.
|
||||||
|
|
@ -162,10 +165,10 @@ class RegexOptions(OptionsDictValidator):
|
||||||
# This tries to scrape a date from the description and produce new
|
# This tries to scrape a date from the description and produce new
|
||||||
# source variables
|
# source variables
|
||||||
match:
|
match:
|
||||||
- "([0-9]{4})-([0-9]{2})-([0-9]{2})"
|
- '([0-9]{4})-([0-9]{2})-([0-9]{2})'
|
||||||
# Exclude any entry where the description contains #short
|
# Exclude any entry where the description contains #short
|
||||||
exclude:
|
exclude:
|
||||||
- "#short"
|
- '#short'
|
||||||
|
|
||||||
# Each capture group creates these new source variables, respectively,
|
# Each capture group creates these new source variables, respectively,
|
||||||
# as well a sanitized version, i.e. `captured_upload_year_sanitized`
|
# as well a sanitized version, i.e. `captured_upload_year_sanitized`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue