I googled but not able to find any good solution which will validate the input string is correct for ISO Duration Format, if any one has any idea or solution may be using regexp or function, will help a lot.
Note: The format for a duration is [-]P[n]DT[n]H[n]M[n][.frac_secs]S
where n specifies the value of the element (for example, 4H is 4 hours). This represents a subset of the ISO duration format and any other duration letters (including valid ISO letters such as Y and M) result in an error.
Example 1,
input string = "P100DT4H23M59S";
expected output = 100 04:23:59.000000
Example 2,
input string = "P2MT12H";
expected output = error, because the month designator, '2M', isn't allowed.
Example 3,
input string = "100 04:23:59";
expected output = 100 04:23:59.000000
.