?
Solved

Count number of numbers in line

Posted on 2000-02-26
11
Medium Priority
?
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

752 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