?
Solved

Count number of numbers in line

Posted on 2000-02-26
11
Medium Priority
?
203 Views
Last Modified: 2010-03-05
Hello,

How to count the number of numbers in the folling line.

$test = "1232344556";

The result has to be 10!

How to do that!!

greetings Michel
0
Comment
Question by:mmcw
  • 7
  • 4
11 Comments
 
LVL 8

Accepted Solution

by:
shlomoy earned 400 total points
ID: 2562178
$test="1232344556";
$test=~s/(\d)/$1 /g;
## 1 2 3 2 3 4 4 5 5 6
@test=split " ", $test;
$number_of_numbers = @test;
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2562179
Of course,

$number_of_numbers = length $test;

as well....

(which is a faster way...).
0
 

Author Comment

by:mmcw
ID: 2562199
Not what I do is the
following

example!!

$number_of_numbers = "60";

$number_of_numbers = $number_of_numbers/40;

The result is 1.5

What I now need is that number will be roundoff up.

$number_of_numbers has to become 2.

But this roundoff has to be done not as we normal round off a number, but by the following way!!

0.5 becomes 1
0.2 becomes 1
1.2 becomes 2
4.7 becomes 5
3.02 becomes 4

How to do that!!






0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:shlomoy
ID: 2562214
That's another question, dude :-)
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2562216
Do you accept my answer to your question?
0
 

Author Comment

by:mmcw
ID: 2562218
Of course, but can you help me??
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2562220
Yes, But please post your new question as a seperate one.
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2562247
for example:
$number=56987658.09728794645;

$number=~m/(\d+)(\.)?(\d+)?/; $number=$1;
if ($2 && $3) {
   $number++ if $3>0;
}
print "$number\n";
0
 

Author Comment

by:mmcw
ID: 2562413
Adjusted points to 100
0
 

Author Comment

by:mmcw
ID: 2562414
I increaded the point to 100!!

Thank you again!!
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2562417
Welcome.
Ask more questions :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question