A regular expression expert might have a nice pattern to scan and find all matches, but that is beyond my REGEX skills.
I have provided two solutions that can be done using column formulas. Both might need some explanation.
The first uses nested character functions, the second uses the ShortestEditScript() function. By the way, you did not specify if you are counting T sequences prior to (N1), both use the entire string. The example table is attached and explanations are below
Assume s2 = "(N1:25252525)AACCAA(N1)GACGTTAACAGTTCTTTG";
Character functions: Words(), Sort List(), Reverse(), list[n], Length()
Length(Reverse(Sort List(words(s2,"ACGN():0123456789")))[1]);
Here is the log output for the respective functions
//:*/
words(s2,"ACGN():0123456789")
/*:
{"TT", "TT", "TTT"}
//:*/
Reverse(Sort List(words(s2,"ACGN():0123456789")))
/*:
{"TTT", "TT", "TT"}
//:*/
Reverse(Sort List(words(s2,"ACGN():0123456789")))[1]
/*:
"TTT"
//:*/
Length(Reverse(Sort List(words(s2,"ACGN():0123456789")))[1]);
/*:
3
ShortestEditScript() is an interesting function. Script 9_Extra_ShortestEditDistance.jsl written for JSL Companion, Applications of the JMP Scripting Language Second Edition document 4 different methods for using this powerful and useful function. For this example, I am using Sequnces() and requesting matrix output. It would take too much space to document this completely, in this forum, so I will just show the results and add a few comments.
msed = Shortest Edit Script( Strings(s2, Repeat("T",length(s2)),matrix(1)) );
maximum(msed[loc(msed[0,1]==0),4]);
The two strings being compared are s2 and a string of all T's created by function Repeat("T", length(s2) ).
msed = Shortest Edit Script( Strings(s2, Repeat("T",length(s2)),matrix(1)) );
/*:
[-1 1 . 27,
0 28 1 2,
-1 30 . 5,
0 35 3 2,
-1 37 . 1,
0 38 5 3,
-1 41 . 1,
1 . 8 34]
/* The matrix output n x 4 where n = nrow(msed)
Column1: -1 | 1| 0 -1-->remove, 1-->insert, 0-->common
Column2: position in the 1st string .-->missing / not found
Column3: position in the 2nd string .-->missing / not found
Column4: length
*/
So now it is a matter of finding the locations in the 1st column of the matrix with 0's (matches/common/T's) this can be done with the loc() function. Then the length of the matching sequence is in the 4th column, so just find the maximum. Note msed[0,1] represents the 1st column of the matrix msed.
loc(msed[0,1]==0)
/*:
[2, 4, 6]
//:*/
msed[loc(msed[0,1]==0),4]
/*:
[2, 2, 3]
//:*/
maximum(msed[loc(msed[0,1]==0),4]);
/*:
3
It will be interesting to see other solutions.