112k views
4 votes
In a regular expression string, what is used to match a series of characters 4 digits in length, at the end of a line?

User Jlareau
by
5.7k points

1 Answer

5 votes

Answer:

\d{4}$

Step-by-step explanation:

In regular expression, the '\d' is used to match digits (from 0 to 9). The '{4}' simply to denote the number of digits needed to match (in this case, 4 in length). Finally, in order to match at the end of the line, the '$' is added.

Therefore the regular expression string for this is

\d{4}$

User J Burnett
by
6.3k points