Jump to content
Sign in to follow this  
qwertylol

strnig parsing

Recommended Posts

qwertylol

4.9.1.2.3.3.4.0.0.4.2.3.4.9.8.4.0.0.0.0.4.2.3.4.9.0.0.0.2.3.8.3.2.

I am trying to parse strings like above,

the rules are:

1) input strings between zeros into separate groups.

2) ignore the 0s unless there are:

a) one of them, ignore 0.

:) two of them, ignore 0.

c) three of them, input 0.

d) four of them, input 0.0.

e) more than 4 of them, ignore.

so the above string would be parsed as:

1) 4.9.1.2.3.3.4.

2) 4.2.3.4.9.8.4.

3) 0.0.

4) 4.2.3.4.9.

5) 0.

6) 2.3.8.3.2.

how do I do this?

it seems that this is more complicated than String Regular expression can handle

Edited by qwertylol

Share this post


Link to post
Share on other sites
qwertylol

$string = StringRegExp($string, '[^0]{1,}', 3)

I tried that, didn't work.

Share this post


Link to post
Share on other sites
qwertylol

how do I parse this ?

Share this post


Link to post
Share on other sites
SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
qwertylol

http://perldoc.perl.org/perlre.html#Regular-Expressions

that's not au3 ! :)

Share this post


Link to post
Share on other sites
qwertylol

actually, how about:

just separate the non zero portion from the zeros?

from this

4.9.1.2.3.3.4.0.0.4.2.3.4.9.8.4.0.0.0.0.4.2.3.4.9.0.0.0.2.3.8.3.2.

into this

4.9.1.2.3.3.4.

0.0.

4.2.3.4.9.8.4.

0.0.0.0.

4.2.3.4.9.

0.0.0.

2.3.8.3.2.

?

Share this post


Link to post
Share on other sites
SmOke_N

that's not au3 ! :)

No, but it's the same regexp type of format that autoit uses. Consider this me teaching you how to fish, rather than giving you the fish itself.

Edit:

Here, this will get you started:

#include <array.au3>
$sString = '4.9.1.2.3.3.4.0.0.4.2.3.4.9.8.4.0.0.0.0.4.2.3.4.9.0.0.0.2.3.8.3.2.'
$aArray = StringRegExp($sString, '[1-9\.]+|[0\.]+', 3)
_ArrayDisplay($aArray, 'Output')
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
qwertylol

No, but it's the same regexp type of format that autoit uses. Consider this me teaching you how to fish, rather than giving you the fish itself.

Edit:

Here, this will get you started:

#include <array.au3>
$sString = '4.9.1.2.3.3.4.0.0.4.2.3.4.9.8.4.0.0.0.0.4.2.3.4.9.0.0.0.2.3.8.3.2.'
$aArray = StringRegExp($sString, '[1-9\.]+|[0\.]+', 3)
_ArrayDisplay($aArray, 'Output')

aw, I'll have to chew that slowly :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×