Reg expression for finding expression in sentence I have a regular expression that match the string that contains the word "duration", followed by a &lt; or &gt; operator and then a number. Here is the expression:

duration\s*(&lt;|&gt;)\s*([0-9]+)


Is there any way I can make this expression better?
Since you only have two characters to compete with, namely, &lt; and &gt;, use a character set. Other than that, you might consider \d matching your digits, instead of 0-9 as \d covers the numerical characters across the entire UTF8 range.

The final expression would be:

duration\s*([&lt;&gt;])\s*(\d+)


I've left the matching groups in place, considering that you might be referencing them in your later code.