Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old January 17th, 2013, 12:45 PM
newtonperri newtonperri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 34 newtonperri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 21 m 20 sec
Reputation Power: 1
Quote:
Originally Posted by Jacques1
So what solution are you going now with? You cannot have both.


Ok thanks,
No idea, the one that works best. But as none works for me, at the moment I am not going with anyone

Reply With Quote
  #17  
Old January 17th, 2013, 12:52 PM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,872 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 1 h 24 m 30 sec
Reputation Power: 813
I'm saying that it makes no sense (and it's annoying) to have a discussion with two people about two different approaches at the same time.

First decide if you gonna have two input fields or one. Then we can discuss what you need to do to get it working.

Two fields are more robust and easier to handle. A single field requires some work and regex magic.

Reply With Quote
  #18  
Old January 17th, 2013, 01:14 PM
newtonperri newtonperri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 34 newtonperri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 21 m 20 sec
Reputation Power: 1
Quote:
Originally Posted by Jacques1
I'm saying that it makes no sense (and it's annoying) to have a discussion with two people about two different approaches at the same time.

Thats correct, I am open to both, I suppose one looks more professional, but the most important is that it works, as both are understandable for the user.
Maybe itīs better to keep talking about 2 fields in the original post in php forum not to destroy this as the regex solution can be interisting for other and not only for me:
http://forums.devshed.com/php-devel...00t-938128.html

Reply With Quote
  #19  
Old January 17th, 2013, 01:36 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,809 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 18 h 6 m 48 sec
Reputation Power: 6112
That script I put in my post, when pasted into a PHP interpreter, prints out all 3 correctly formatted prices. Note that it's a PHP script.
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #20  
Old January 17th, 2013, 01:50 PM
newtonperri newtonperri is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 34 newtonperri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 21 m 20 sec
Reputation Power: 1
Quote:
Originally Posted by ManiacDan
That script I put in my post, when pasted into a PHP interpreter, prints out all 3 correctly formatted prices. Note that it's a PHP script.

Thanks,
I use php and this does not print out anything for me, only the word test:
PHP Code:
<?php
$a 
'1.457,54';
 function 
strip($a) { 
{   return 
preg_replace("/^(.+?)([\.,](\d{2}))?$/e""str_replace(array(',','.'),'','\\1') . str_replace(',','.','\\2')"$a); 
}
echo 
strip('123,456,78');
#123456.78
echo strip('123,456.78');
#123456.78
echo strip('123.456,78');
#123456.78 
 
echo $a;
 }

 echo 
"test";
?>

Reply With Quote
  #21  
Old January 18th, 2013, 04:59 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 511 Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Laurent_R User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Days 19 h 57 m 48 sec
Reputation Power: 405
I think you should just force your user to use only one format (chose what you wish, American or European, and just stick to it): provide an example of how the amount should be formatted, for example either "1234,56" or "1234.56", and just refuse to validate any amount that does not match your format (with just a possible exception if the user enters an amount with neither a dot nor a comma, in which case it can be considered to be a round dollar or euro amount).

There is nothing wrong, in a user interface, to force the user to to something in the correct way if this correct way is explained clearly in the interface, and this is even a very good thing to to if this can prevent any ambiguity, especially when monetary amounts are at stake.

Of course, having two fields is perhaps even better and more robust, but I have seen many applications (including banking interfaces where you have to enter the amount you want to wire) where just one field enforcing strict rules just does the job right.

Last edited by Laurent_R : January 18th, 2013 at 05:04 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Strip out all non-numerics except the last decimal

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap