Hello world! for Regex
Pinch of regex is what you need when writing a preprocessing code for ML
Commonly used regex for data preprocessing
Adding a space before a punctuation if it is not already spaced.
import re
ex_str = 'This house is very old.'
ex_str = re.sub(r"([?.!,])", r" \1 ", ex_str)
ex_str = re.sub(r'[" "]+', " ", ex_str)
ex_str = re.sub("[^a-zA-Z?.!]+". " ", w)
ex_str = ex_str.strip()
print(ex_str)
- Identifiers
*
.
+
?
[]
\1
.*
.+
-
.?
10.