@ryleigh
Normalizing text with regex involves replacing or modifying text patterns to make them uniform and consistent. Here are some common ways to normalize text using regex:
- Removing extra spaces: Use the regex pattern s+ to match one or more whitespace characters, and replace them with a single space.
- Removing special characters: Use the regex pattern [^a-zA-Z0-9s] to match any characters that are not letters, numbers, or whitespace, and replace them with an empty string.
- Converting to lowercase: Use the regex pattern [A-Z] to match uppercase letters, and replace them with their lowercase equivalents using the .toLowerCase() function.
- Removing accents: Use the regex pattern [^-] to match any non-ASCII characters, and replace them with their ASCII equivalents.
- Normalizing whitespace: Use the regex pattern s+ to match one or more whitespace characters, and replace them with a single space.
- Removing leading and trailing spaces: Use the regex pattern ^s+|s+$ to match leading and trailing spaces in a string, and replace them with an empty string.
By using these regex patterns in combination with text processing functions, you can easily normalize text to make it more consistent and easier to work with.