You can use capture groups and backlinks :
^(\\d+)=\\1$
[Labels should prevent something else]
Perhaps a more convincing expression would look like this:
^\\s*(\\d+)\\s*=\\s*\\1\\s*$
What takes ignores possible spaces that might otherwise not work as expected. Of course, now it depends on whether you say, for example, that 1 =1 is a valid input string.
A more general expression might be:
^\\s*(.+?)\\s*=\\s*\\1\\s*$
Where you can compare any line before the equal sign. .+? matches any character before the equal sign.
Jerry
source share