Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Removing Duplication from Regular Expression String declaratio in Java

$
0
0
The following regex is used to extract hex values from a .cap file.

final String theRegex = "[a-f0-9]{4}:\\s[a-f0-9]{2}\\([a-f0-9}{2}\\s)?([a-f0-9}{2}\\s)?([a-f0-9}{2}\\s)?([a-f0-9}{2}\\s)?; ...etc.


There appears to be a pattern
([a-f0-9}{2}\\s)?
but how can you improve readability?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>