I'm trying to write a pattern where a line should begin with a digit AND end with a digit. The problem that I face is that both conditions should occur together (starts with and ends with).
Can any one point how this should work? for code simplicity I need to write one pattern (not to use startsWith or endsWith)
If you are going to use Matcher.matches() then there is no need for the '^' or the '$' since they are implicit when using matches() and all you need is -
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
I'd change that into "\\d(.*\\d)?", to also allow lines with only one single digit. Those too meet the requirements of both starting and ending with a digit - they just happen to be the same.