Letβs now come to the example usage of the characters we listed in the table on this post. We will use the βdβ and β+β characters to find only numbers in the content entered.
/d+/g
This example only matches the numbers 1234, 321 789. With the setting βgβ, we expressed the comprehensive search, not just once.
At the beginning of the β+β character, which denotes one or more repetitions, we wrote βdβ, which denotes any number. For a more useful example, letβs catch the expression written in date format in the content entered.
/(d{2}.d{2}.d{4})/g
Do not scare yourself and be confused, you can summarize what happened when you extract it by examining the relevant places. d{2}
the number 2, after. We expressed the point .
with the escape character, and the number 4 in the last part. So it will match content like 19.03.2021
.