Right now we don't want to be panicking if the user provides an invalid regex. We also don't really want to be throwing or returning an error, this will mess with any live preview that is going on in external tools. We should return the input and let any preview display the text. This will happen if the user is doing some preview as you type kind of thing.
25 lines
814 B
Gherkin
25 lines
814 B
Gherkin
Feature: Regex search and replace
|
|
|
|
Scenario: You can search and replace with with a regular expression
|
|
Given Search is '(\w+)'
|
|
And Replace is 'new'
|
|
And Input is 'this is a'
|
|
Then Output is 'new new new'
|
|
|
|
Scenario: You can use a '$' to replace a match group
|
|
Given Search is 'function (\w+)\(\)'
|
|
And Replace is 'fun $1()'
|
|
And Input is 'function foo()'
|
|
Then Output is 'fun foo()'
|
|
|
|
Scenario: You can will need to wrap the match group when the match is against another word
|
|
Given Search is 'Hello (\w+)'
|
|
And Replace is 'Hello ${1}s'
|
|
And Input is 'Hello world'
|
|
Then Output is 'Hello worlds'
|
|
|
|
Scenario: You can search with an invalid regular expression
|
|
Given Search is '(\w+'
|
|
And Replace is 'new'
|
|
And Input is 'this is a'
|
|
Then Output is 'this is a'
|