One formula option:
<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]4215[/TD]
[TD="align: right"]5142[/TD]
[TD="align: right"]TRUE[/TD]
[TD="align: right"]TRUE[/TD]
</tbody>
Sheet3
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]C1[/TH]
[TD="align: left"]=AND(
SMALL(MID(A1,{1,2,3,4},1)+0,{1,2,3,4})=SMALL(MID(B1,{1,2,3,4},1)+0,{1,2,3,4}))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]D1[/TH]
[TD="align: left"]{=IFERROR(
AND(SMALL(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)+0,ROW(INDIRECT("1:"&LEN(A1))))=SMALL(MID(B1,ROW(INDIRECT("1:"&LEN(B1))),1)+0,ROW(INDIRECT("1:"&LEN(B1))))),FALSE)}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
The formula in C1 works for 2 4-digit numbers. Not too terrible. The formula in D1 works for 2 numbers of arbitrary size (a bit messier!) Both only work on numbers, no letters.