Click here to Skip to main content
15,891,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
16.726--5.670--25.129**16.312--5.718--22.847**14.366--5.258--25.545**16.920--3.457--25.425**19.419--6.712--25.198**18.536--7.602--25.240**19.152--5.518--24.957**15.501--7.808--24.644**16.883--6.024--27.528**

I have to split the numbers. Remove those ** and -- between numbers and store in single variable( $points ). I have to do this in perl. i have provided the code till removing of ** between the numbers.

output of $points  : 16.726 5.670 25.129 16.312 5.718 22.847 14.366 5.258 25.545 16.920 3.457 25.425 19.419 6.712 25.198 18.536 7.602 25.240 19.152 5.518 24.957 15.501 7.808 24.644 16.883 6.024 27.528

Thanks in advance.


What I have tried:

$points = "16.726--5.670--25.129**16.312--5.718--22.847**14.366--5.258--25.545**16.920--3.457--25.425**19.419--6.712--25.198**18.536--7.602--25.240**19.152--5.518--24.957**15.501--7.808--24.644**16.883--6.024--27.528**";
@pointss = split(/\*\*/,$points);
print "@pointss\n";
Posted
Updated 30-Mar-17 12:59pm
v2

Just use an alternation:
PERL
@pointss = split(/\*\*|--/, $points);
 
Share this answer
 
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900