-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
#895) * regexFirstGroup return first group from regexp, useful with .env files and another config files * documentation about regexFirstGroup and example * modify func regexFirstGroup to findStringSubmatch, return all the submatchs from regex * func findStringSubmatch(), returns map[string]interface{} for use with get and named parenthesized subexpressions or stringfied array string
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -918,6 +918,31 @@ Available functions: | |
`toUpper` | ||
: Changes piped input to UPPERCASE | ||
|
||
|
||
Check failure on line 921 in docs/gossfile.md GitHub Actions / Lint DocumentationTrailing spaces
Check failure on line 921 in docs/gossfile.md GitHub Actions / Lint DocumentationMultiple consecutive blank lines
|
||
`findStringSubmatch regex string` | ||
: Returns map[string]interface{} with the names of the parenthesized subexpressions, like `(?P<first>[a-z])` | ||
|
||
Check failure on line 924 in docs/gossfile.md GitHub Actions / Lint DocumentationTrailing spaces
|
||
{{ $regexDBrc := "\\'mysql:\\/\\/(?P<login>[a-z0-9]+):(?P<password>[a-z0-9]+)@localhost\\/(?P<database>roundcube_[a-z0-9]+)\\';"}} | ||
|
||
{{ $rcConf := readFile /home/user/roundcube/config.inc.php | findStringSubmatch $regexDBrc }} | ||
{{ $UserDBrc := get $rcConf "login" }} | ||
{{ $PassDBrc := get $rcConf "password" }} | ||
{{ $DBrc := get $rcConf "database" }} | ||
|
||
If not exists named parenthesized subexps, returns stringfied array string: | ||
|
||
{{ $regexDBrc := "\\'mysql:\\/\\/([a-z0-9]+):([a-z0-9]+)@localhost\\/(roundcube_[a-z0-9]+)\\';"}} | ||
|
||
{{ $rcConf := readFile /home/user/roundcube/config.inc.php | findStringSubmatch $regexDBrc }} | ||
{{ $UserDBrc := get $rcConf "1" }} | ||
{{ $PassDBrc := get $rcConf "2" }} | ||
{{ $DBrc := get $rcConf "3" }} | ||
|
||
NOTE: stringfied string array begins with "1" ("0" is all the string matched) | ||
|
||
|
||
Check failure on line 943 in docs/gossfile.md GitHub Actions / Lint DocumentationTrailing spaces
Check failure on line 943 in docs/gossfile.md GitHub Actions / Lint DocumentationMultiple consecutive blank lines
|
||
|
||
Check failure on line 944 in docs/gossfile.md GitHub Actions / Lint DocumentationMultiple consecutive blank lines
|
||
|
||
Check failure on line 945 in docs/gossfile.md GitHub Actions / Lint DocumentationMultiple consecutive blank lines
|
||
!!! warning | ||
|
||
gossfiles containing text/template `{{}}` controls will no longer work with `goss add/autoadd`. | ||
|