C
Cheez
Hello, hard to desribe my question in a clear way. I want to process
a string that looks like this:
$mystring = "thetextinherewillbefairlyrandom";
I want to capture chunks of text and place them in an array or hash
table. If possible, I want to make a regex that will start at the
first letter and capture letters 1 - 5, in this case $capture =
"thete". Then, I want this window to shift 1 letter so that the next
captured string is letters 2 - 6, or $capture= "hetex" and so on until
the end of the line. Can anyone offer up a sample regex would
accomplish this task?
Thanks,
Cheez
==============================================
My idea is this (although it doesn't work):
$mystring = "thetextinherewillbefairlyrandom";
$length = scalar ($mystring);
while ($counter < $length) {
$_ =~ /\w[$counter-$counter+4]/; # 'capture' regex
push @newarray; $counter++; # regex capture window increments by
1
# pushing chunks into array
}
foreach (@newarray) { #sample output
print "$newarray";
}
a string that looks like this:
$mystring = "thetextinherewillbefairlyrandom";
I want to capture chunks of text and place them in an array or hash
table. If possible, I want to make a regex that will start at the
first letter and capture letters 1 - 5, in this case $capture =
"thete". Then, I want this window to shift 1 letter so that the next
captured string is letters 2 - 6, or $capture= "hetex" and so on until
the end of the line. Can anyone offer up a sample regex would
accomplish this task?
Thanks,
Cheez
==============================================
My idea is this (although it doesn't work):
$mystring = "thetextinherewillbefairlyrandom";
$length = scalar ($mystring);
while ($counter < $length) {
$_ =~ /\w[$counter-$counter+4]/; # 'capture' regex
push @newarray; $counter++; # regex capture window increments by
1
# pushing chunks into array
}
foreach (@newarray) { #sample output
print "$newarray";
}