-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is useful in case the string to use as replacement contains leading or trailing whitespace. This should function as a workaround for #6. Thanks to @Simran-B for the suggestion!
- Loading branch information
Showing
4 changed files
with
92 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
# `replace-string` GitHub Action | ||
|
||
Replaces strings with regular expressions. | ||
|
||
## Inputs | ||
|
||
### `pattern` | ||
|
||
**Required** Regular expression to match. | ||
|
||
### `string` | ||
|
||
**Required** Input string. | ||
|
||
### `replace-with` | ||
|
||
**Required** String to use for replacement. | ||
|
||
### `flags` | ||
|
||
Flags to use when matching. Please refer to [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) for more information. | ||
|
||
## Outputs | ||
|
||
### `replaced` | ||
|
||
The replaced string. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: frabert/[email protected] | ||
with: | ||
pattern: 'Hello, (\w+)!' | ||
string: 'Hello, world!' | ||
replace-with: 'I greet you, $1!' | ||
``` | ||
# `replace-string` GitHub Action | ||
|
||
Replaces strings with regular expressions. | ||
|
||
## Inputs | ||
|
||
### `pattern` | ||
|
||
**Required** Regular expression to match. | ||
|
||
### `string` | ||
|
||
**Required** Input string. | ||
|
||
### `replace-with` | ||
|
||
**Required** String to use for replacement. | ||
|
||
### `flags` | ||
|
||
Flags to use when matching. Please refer to [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) for more information. | ||
|
||
### `json` | ||
|
||
Boolean. Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub. | ||
|
||
## Outputs | ||
|
||
### `replaced` | ||
|
||
The replaced string. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: frabert/[email protected] | ||
with: | ||
pattern: 'Hello, (\w+)!' | ||
string: 'Hello, world!' | ||
replace-with: 'I greet you, $1!' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
name: 'Replace string' | ||
author: 'Francesco Bertolaccini' | ||
description: 'Use regular expressions to manipulate strings' | ||
inputs: | ||
pattern: | ||
description: 'Regular expression pattern' | ||
required: true | ||
string: | ||
description: 'The input string' | ||
required: true | ||
replace-with: | ||
description: 'What to replace with' | ||
required: true | ||
flags: | ||
description: 'Flags to use when matching' | ||
required: false | ||
outputs: | ||
replaced: | ||
description: 'The output string' | ||
runs: | ||
using: 'node12' | ||
main: 'index.js' | ||
branding: | ||
icon: 'search' | ||
name: 'Replace string' | ||
author: 'Francesco Bertolaccini' | ||
description: 'Use regular expressions to manipulate strings' | ||
inputs: | ||
pattern: | ||
description: 'Regular expression pattern' | ||
required: true | ||
string: | ||
description: 'The input string' | ||
required: true | ||
replace-with: | ||
description: 'What to replace with' | ||
required: true | ||
flags: | ||
description: 'Flags to use when matching' | ||
required: false | ||
json: | ||
description: 'Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub' | ||
required: false | ||
outputs: | ||
replaced: | ||
description: 'The output string' | ||
runs: | ||
using: 'node12' | ||
main: 'index.js' | ||
branding: | ||
icon: 'search' | ||
color: gray-dark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters