replace regex crate with fancy_regex (#14646)

# Description

We removed the regex crate long ago but there were a few instances where
we could not remove it because fancy-regex did not have a split/splitn,
and maybe other functions. Those functions now exist in the latest
fancy-regex crate so we can now remove it.
 
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
This commit is contained in:
Darren Schroeder
2025-01-01 17:37:50 -06:00
committed by GitHub
parent c6523eb8d9
commit f69b22f00b
9 changed files with 181 additions and 124 deletions

View File

@ -1,5 +1,5 @@
use fancy_regex::Regex;
use nu_test_support::{nu, playground::Playground};
use regex::Regex;
#[test]
fn record_with_redefined_key() {
@ -45,7 +45,7 @@ fn test_eval(source: &str, expected_out: ExpectedOut) {
Matches(regex) => {
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
assert!(
compiled_regex.is_match(&actual.out),
compiled_regex.is_match(&actual.out).unwrap_or(false),
"eval out does not match: {}\n{}",
regex,
actual.out,
@ -55,7 +55,7 @@ fn test_eval(source: &str, expected_out: ExpectedOut) {
Error(regex) => {
let compiled_regex = Regex::new(regex).expect("regex failed to compile");
assert!(
compiled_regex.is_match(&actual.err),
compiled_regex.is_match(&actual.err).unwrap_or(false),
"eval err does not match: {}",
regex
);