public static String getOffsetCodeFromCurveName ( String curveName ) { if ( curveName == null || curveName . length ( ) == 0 ) { return null ; } String [ ] splits = curveName . split ( "(?<=\\D)(?=\\d)" ) ; String offsetCode = splits [ splits . length - 1 ] ; if ( ! Character . isDigit ( offsetCode . charAt ( 0 ) ) ) { return null ; } offsetCode = offsetCode . split ( "(?<=[A-Za-z])(?=.)" , 2 ) [ 0 ] ; offsetCode = offsetCode . replaceAll ( "[\\W_]" , "" ) ; return offsetCode ; }
Determines the offset code of a forward contract from the name of a forward curve . This method will extract a group of one or more digits together with the first letter behind them if any . If there are multiple groups of digits in the name this method will extract the last . If there is no number in the string this method will return null .