queue - Java age approximation from an input -


i have problem prioritizing age

these here inputs need processed

dude 20-25 major injuries guy 48 panic  bob <=4  

i have prioritize must saved age of victim (young elder) can see number/s after name of victim age

so if range beetwen 20-25 considered 20

  • if <=4 considered 4
  • if <4 considered 3
  • if >4 considered 5

my question is, best way process each line can considered value age need store somewhere in array or arraylist if was:

dude 20-25 major injuries 

it change dude 20 major injuries

i need idea process it, doesnt need code.

you use regular expressions , replace terms rules. here small example first rule:

string input = "dude 20-25 major injuries"; pattern pattern = pattern.compile("([^\\d]*)([\\d]+)-([\\d]+)(.*)"); matcher matcher = pattern.matcher(input); matcher.matches(); string output = matcher.group(1) + matcher.group(2) + matcher.group(4); system.out.println(input); system.out.println(output); 

output:

dude 20-25 major injuries dude 20 major injuries 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -