Ransford Okpoti's Blog

13 August, 2016

A Regular Expression (RegEx) To Match Integers and Doubles

Filed under: Java, JavaScript, Programming — ranskills @ 6:05 am

These regular expressions matches both the positive and negative variations of the data types specified below

  • integers – e.g., 1, 89, 81223, -7, etc.
  • floating point numbers (doubles or floats) – e.g., .0, 59.3, 300.12, -.87


The adopted approach was to avoid nested expressions which is not needed if it is only the number that is of interest and not its components like the decimal part and the fractional part.


var numberRegex = /(\-?\d*\.?\d+)/;

// Testing
var testNumber = "-45.8974";



String numberRegex = "(\\-?\\d*\\.?\\d+)";


Coming soon.



The site below allows the building and testing of regular expressions online, it is really nice with some colour coded tags and parenthesis colour matching to make a really complicated regular expression bearable to spot errors.




31 July, 2016

Forcing Maven To Use The Local .m2 Repository

Filed under: Java — ranskills @ 6:54 am

If each Maven run on a project results in always downloading dependency jars even though they have already been downloaded and stored in your local .m2 repository which is by default located at USER_HOME/.m2 e.g., on my Windows 10 machine, mine is C:\Users\ransk\.m2, then you only have to instruct Maven to operate in an offline mode.

One way to do is to locate the main Maven install directory, this is referred to as the MAVEN_HOME, which contains the settings.xml file in the conf directory, e.g. E:\tools\apache-maven-3.3.9\conf\settings.xml.

The offline settings is off by default and it only has to be turned on by ensuring you have the entry below in the settings.xml file.


With this in place, Apache Maven will check to see if required dependencies are available locally before contacting any remote repositories.

Blog at WordPress.com.