Regular Expression - {} - matches custom numbers of the previous single expression

The curly braces ({}) match with a specified number or range of occurrences of the previous single expression.

  • ={80} - A single number in the braces means exactly that number - in this case match 80 equals signs
  • ={60,80} - Two comma separated numbers in the braces means a range - in this case match 60-80 equals signs (inclusive)
  • ={60,} - A single number followed by a comma in the braces means at least that number - in this case match 60 or more equals signs
  • ={1,80} - Match between between 1 and 80 equals signs
  • !={0,80}! - Match two exclamation marks separated by 0 to 80 equals signs

Examples

Match line with 3,4 or 5 equals signs:

={3,5}
This would match the following:
===
====
=====
It would not match the following:
==

Match line with 3 or more equals signs:

={3,}
This would match the following:
===
====
===============================
It would not match the following:
==

Match line with exactly 3 equals signs:

={3}
This would match the following:
===
It would not match the following:
==
====
===============================

Computing Articles