mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
Refactor find
to handle regex search and non-regex search the same way (#15839)
# Description Regex search and search with directly provided search terms used to follow two different code paths. Now all possible search options get turned into a regex, with optional additional search options, and handled using a unified code path which mostly follows the logic of the current term code path. # User-Facing Changes Regex search will now behave in the same way as non-regex search: - split multiline strings into lists of lines, and filter out the lines that don't match - highlight matching string sections (unless --no-highlight flag is used) - search through the specified record columns if the --columns flag is used The behavior of non-regex search should be unaffected by this commit.
This commit is contained in:
@ -118,7 +118,10 @@ fn find_with_regex_in_table_keeps_row_if_one_column_matches() {
|
||||
"[[name nickname]; [Maurice moe] [Laurence larry]] | find --no-highlight --regex ce | get name | to json -r"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, r#"["Maurice","Laurence"]"#);
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
r#"["\u001b[37mMauri\u001b[0m\u001b[41;37mce\u001b[0m\u001b[37m\u001b[0m","\u001b[37mLauren\u001b[0m\u001b[41;37mce\u001b[0m\u001b[37m\u001b[0m"]"#
|
||||
);
|
||||
assert_eq!(actual_no_highlight.out, r#"["Maurice","Laurence"]"#);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user