Knuth--Morris--Pratt can be modified straightforwardly to yield, for each position in the haystack string, the length of the longest prefix of the needle string with a match ending at that position. Use KMP to compute this information for Pat1 in String and reverse(Pat2) in reverse(String), then iterate over each position in String looking for the maximum prefix/suffix length.
Example with String = "OBANTAO" and Pat1 = "BANANA" and Pat2 = "SIESTA":
"BANANA" = Pat1 in String
O B A N T A O
^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | |
| | | | | | | 0 ("")
| | | | | | 0 ("")
| | | | | 0 ("")
| | | | 3 ("BAN")
| | | 2 ("BA")
| | 1 ("B")
| 0 ("")
0 ("")
"ATSEIS" = reverse(Pat2) in reverse(String)
O A T N A B O
^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | |
| | | | | | | 0 ("")
| | | | | | 0 ("")
| | | | | 1 ("A")
| | | | 0 ("")
| | | 2 ("AT")
| | 1 ("A")
| 0 ("")
0 ("")
Reverse the second array and sum componentwise.
0 0 1 2 3 0 0 0
+ 0 0 1 0 2 1 0 0
-----------------
0 0 2 2 5 1 0 0
^
|
max (argument = "BAN" ++ reverse("AT"))