As an example, you can:
\b[az]*(_[az]*){3}[az]*\b
(with flag of ignore flag).
You can play with him here
It says "a match of 0 or more letters, followed by" _ [az] * "exactly three times, followed by 0 or more letters." \b means "word boundary", i.e. "Match the whole word."
Since I used '*', this will correspond if there are exactly three words โ_โ in the word, regardless of whether it appears at the beginning or end of the word - you can change it otherwise.
In addition, I suggested that you want to combine all the words in the line with exactly three "_" in it.
This means that the string "a_b a_b_c_d" will say that "a_b_c_d" is transmitted (but "a_b" does not work).
If you mean that globally throughout the line you only need three "_s", use:
^[^_]*(_[^_]*){3}[^_]*$
This binds the regular expression at the beginning of the line and comes to an end, making sure that it contains only three occurrences of "_".
source share