• Post Reply Bookmark Topic Watch Topic
  • New Topic

regex to check valid long value.  RSS feed

 
Rahul Kakkar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basically i need to check whether the value entered for a serialVersionUID (type = long) for a serializable class is valid or not. could someone please provide me with the regex pattern to check for this?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by valid? A serialVersionUID is a long data type, so what is an allowable value is rather well-defined (and you would have problems trying to stuff an out-of-range value into it).
 
Rahul Kakkar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for being unclear. the input is of type String, so i want to ensure that the String inputted is a valid long value and obviously only numerical values. (also no 'L' or 'l' at the end)
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do a "Long.parseLong(String)", and catch the exception that is thrown if the argument is not a valid long.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!