Skip to content

Instantly share code, notes, and snippets.

@fbender
Last active August 29, 2015 14:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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