Extract a substring from a file

Hello,
A question please.
A have a file that contains a string. Ex:

AAAABBCCCCCDDEEEEEEEEEEFF

I'd want to recover 2 substrings, 'BB' and 'FF' and then leave them in a new file.
From position 5, 2 caracters (ex:"BB") and from position 25, 2 caracters (ex:"FF") in a file.
Could anoyone help me please?
Thanks in advance

Please use code tags as required by forum rules!

How about counting your chars correctly? Try

cut -c5-6,24-25 file
BBFF
awk '{print substr($0, 5, 2)substr($0, 24, 2)}' file
BBFF

Redirect to new file (> newfile) if happy.

Thanks!
I will use

cut -c5-6,24-25 file

and for

"FF" "BB" ? 

I need to add a constant in the beginning too.

thanks

If your file only has one line, you don't need any external commands:

read line < file

Then use parameter expansion to get the characters you want:

# bash
printf "%s%s\n" "${line:4:2}" "${line:23:2}"
# POSIX
temp=${line#????}
s1=${temp%${temp#??}}
temp=${line#???????????????????????}
s2=${temp%${temp#??}}
printf "%s%s\n" "$s1" "$s2"