Skip to content

Instantly share code, notes, and snippets.

@fbender
Last active August 29, 2015 14:02
Show Gist options
  • Save fbender/acf1f17a9ad14625217c to your computer and use it in GitHub Desktop.
Save fbender/acf1f17a9ad14625217c to your computer and use it in GitHub Desktop.
Validate a Fortran number literal in Matlab (Snippet).
validInt = '^\d+$';
ri = regexp(value, validInt);
if size(ri, 2) == 1
% integer
end
validDouble = '^(\d+(\.\d*)?|\.\d+)[dD][+-]?\d{1,3}$';
rd = regexp(value, validDouble);
if size(rd, 2) == 1
% double
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment