You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Capture group names must be any sequence of alpha-numeric Unicode codepoints, in addition to ., _, [ and ]. Names must start with either an _ or an alphabetic codepoint. Alphabetic codepoints correspond to the Alphabetic Unicode property, while numeric codepoints correspond to the union of the Decimal_Number, Letter_Number and Other_Number general categories.
so i consider the expan expression $1_cpu will refer to the capture group index 1. Actually, expand treats it as named capture group 1_cpu, which lead to empty result. This behavior is incorrect, because capture group name cannot start with digit.
What are the steps to reproduce the behavior?
What is the actual behavior?
use regex::Regex;fnmain(){let s = "cpu_user";let rx = Regex::new("cpu_(.*)").unwrap();let caps = rx.captures(s).unwrap();letmut x = String::new();
caps.expand("$1_cpu",&mut x);println!("result = {:?}", x);}
Returns output:
result = ""
What is the expected behavior?
Expected output:
result = "user_cpu"
Other notes
Expanding of ${1}_cpu works as expected. The expression cpu_$1 is already expanded properly.
The text was updated successfully, but these errors were encountered:
What version of regex are you using?
1.8.4
Describe the bug at a high level.
The documentation declares:
so i consider the expan expression
$1_cpu
will refer to the capture group index 1. Actually, expand treats it as named capture group1_cpu
, which lead to empty result. This behavior is incorrect, because capture group name cannot start with digit.What are the steps to reproduce the behavior?
What is the actual behavior?
Returns output:
What is the expected behavior?
Expected output:
Other notes
Expanding of
${1}_cpu
works as expected. The expressioncpu_$1
is already expanded properly.The text was updated successfully, but these errors were encountered: