regex - regular expression to validate hashmap converted string in java servlet -


i trying make regular expression accept both floating , numeric value in java. tried many examples , searched 2 hours got no result. think due using hashmap instead of string.

here code.

    map data = new hashmap(); //hashmap table convert multipart varibles post      list items = null;      boolean flag = true; //flag check if error in validation        try {         items = upload.parserequest(request); //all multipart variables list     } catch (fileuploadexception ex) {         out.println(ex);     }      iterator itr = items.iterator(); //loop of list `items`     while (itr.hasnext())     {         fileitem item = (fileitem) itr.next();         if (item.isformfield()) //if item textbox         {             data.put(item.getfieldname(), item.getstring()); //put in hashtable         }     }     //check if selling rate in decimal or numeric format     if(!pattern.matches((string)data.get("product_selling_rate"), "^[1-9]\\d*(\\.\\d+)?$"))         {             out.print("<li>product rate should contains numbers , decimal point.</li>");             flag = false;         } 

i have tried /^[1-9]\d*(\.\d+)?$/ not worked.

<input type="text" name="product_selling_rate" value="1000"> <input type="text" name="product_selling_rate" value="1000.10"> 

both not worked


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -