"be consistent" PerlMonks

### Puzzlement in Splitsville

by tlm (Prior)
 on Jun 19, 2005 at 12:43 UTC Need Help??

```atgactaatagcagtgg
```
```0 'atg'
1 'act'
...
3 'agc'
4 'agt'
5 'gg'
```
```@codons = grep \$_, split /(.{3})/, 'atgactaatagcagtgg';
print "@codons\n";
__END__
atg act aat agc agt gg
```
```@codons0 = split /(?:.{3})/, 'atgactaatagcagtgg';  # disable capture w
+ith ?:
@codons1 = split /.{3}/,     'atgactaatagcagtgg';  # no parens
...
__END__
::::::gg
::::::gg
```
```@codons = 'atgactaatagcagtgg' =~ /.{1,3}/g;
print "@codons\n";
__END__
atg act aat agc agt gg
```
```@codons = 'atgactaatagcagtgg' =~ /.{3}/g;
print "@codons\n";
__END__
atg act aat agc agt
```
```@parts = '12abc3ef' =~ /[a-z]+|\d+/g;
print "@parts\n";
__END__
12 abc 3 ef
```
```@parts = grep \$_, split /([a-z]+|\d+)/, '12abc3ef';
```
```@parts = split /(?<=[a-z])(?=\d)|(?<=\d)(?=[a-z])/, '12abc3ef';
```
```0 'aaa'
1 'bb'
...
3 'dddd'
4 'a'
5 'ee'
```
```@runs = do { my \$i; grep ++\$i%2, 'aaabbcddddaee' =~ /((.)\2*)/g };
print "@runs\n";
__END__
aaa bb c dddd a ee
```

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://468106]
Approved by BrowserUk
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2018-10-21 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I need money for a bigger acquisition, I usually ...

Results (119 votes). Check out past polls.

Notices?