facebookincubator / fastmod

A fast partial replacement for the codemod tool
Apache License 2.0
1.66k stars 41 forks source link

Regex quantifier of capture group are not kept when replace #27

Closed sluongng closed 3 years ago

sluongng commented 3 years ago

Setup

echo "aaabb" > file

Test

fastmod '(a)*b' '${1}c' file

Expect

aaacb

Actual

a:1
- aaabb
+ acb

Accept change (y = yes [default], n = no, e = edit, A = yes to all, E = yes+edit, q = quit)?
swolchok commented 3 years ago

Shouldn't you need to write your pattern as (a*)b for this to work as expected? As written, it looks like you capture exactly one a.

sluongng commented 3 years ago

You are correct. PEKAC i missed a bracket