Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

?

  • Moderators
Posted (edited)

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.

Posted

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 :)

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
×
×
  • Create New...