mirror of
https://github.com/nushell/nushell.git
synced 2025-02-02 11:39:55 +01:00
enables find to search records with regex (#5100)
* enables find to search records with regex * clippy
This commit is contained in:
parent
d64cf1687e
commit
6e7e2dbb97
@ -187,9 +187,23 @@ fn find_with_regex(
|
||||
.map_err(|e| ShellError::UnsupportedInput(format!("incorrect regex: {}", e), span))?;
|
||||
|
||||
input.filter(
|
||||
move |value| {
|
||||
let string = value.into_string(" ", &config);
|
||||
re.is_match(string.as_str()) != invert
|
||||
move |value| match value {
|
||||
Value::String { val, .. } => re.is_match(val.as_str()) != invert,
|
||||
Value::Record { cols: _, vals, .. } => {
|
||||
let matches: Vec<bool> = vals
|
||||
.iter()
|
||||
.map(|v| re.is_match(v.into_string(" ", &config).as_str()) != invert)
|
||||
.collect();
|
||||
matches.iter().any(|b| *b)
|
||||
}
|
||||
Value::List { vals, .. } => {
|
||||
let matches: Vec<bool> = vals
|
||||
.iter()
|
||||
.map(|v| re.is_match(v.into_string(" ", &config).as_str()) != invert)
|
||||
.collect();
|
||||
matches.iter().any(|b| *b)
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
ctrlc,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user