• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regex help needed  RSS feed

 
David Payne
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want a regex which allows me to generate something like this:

University of <choose randomly from a list of states>. Here, states can be NY, CO, AZ etc.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how a regular expression comes into play here. Those are state names isn't it? Can you explain why you want a regex here?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. Wouldn't you just have a list of states, and then generate names by appending a randomly chosen one to "University of "?

(Regexes are usually used for validation, not generating values).
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:(Regexes are usually used for validation, not generating values).

@David: I think you'll be more interested in String.format().

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!