firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.24k stars 199 forks source link

Wrong Substitution #1960

Closed Elashi closed 1 year ago

Elashi commented 1 year ago

Bug Description

I am trying to substitute a capturing group but it is replaced with more characters than the real matched expression.

Reproduction steps

Regular expression: "([0-9]{3}.[0-9]{1,})([a-z-()0-9])"gim Testing string: 172.313(a) 172.704(a)(4) 172.704(a)(5)* 172.800(b) Substitution:** $2

Actual Outcome

(a) (a)(4) (a)(5) (b)**

Expected Outcome

(a) (a)(4) (a)(5) (b)

Browser

Chrome 108.0.5359.125 (Official Build) (64-bit) (cohort: Stable)

OS

Microsoft Windows 10

Elashi commented 1 year ago

I was using Substitute ; I should have used List