I know the Basics of Regex, today I learnt something new:
When copying code, I always had the urge to change from this:
.then(function(response) {
to this:
.then((response) => {
So today, I just built a solution.
To get this result, using Visual Studio Code,
hit CMD + H, then Alt + R,
to open the Replace Window and include Regex.
First Box: function\((.*)\)\s*{
Second Box: ($1) => {
Explanation:
function => the word "function" \( => escaped ( ( => open capturing group .* => zero or more times any single character => captured group ) => close capturing group \) => escaped ) \s* => zero or more times whitespace { => { ($1) => use the the captured group => { => => {
Top comments (0)