MATLAB: Regular Expressions using regexp

expressionMATLABregexpstring

Hello, I have some problem with understanding regexp expression
I have some names: ["T_24_UZK500.txt"; "FWD_T80_UZK500.txt"; "T80_UZK700.txt"]
how can I get numbers after "T" and after "UZK"?
I need a rule that will describe only the numbers after the designated patterns.

Best Answer

Matching only integer numbers after 'UZK' or 'T_' (it is unclear in your question if the underscore is permitted or not, but the regular expression below is easy to adapt):
>> S = {'T_24_UZK500.txt';'FWD_T80_UZK500.txt';'T80_UZK700.txt'};
>> C = regexp(S,'(?<=(T_?|UZK))\d+','match');
>> C{:}
ans =
'24' '500'
ans =
'80' '500'
ans =
'80' '700'
Or simply by matching any integer numbers:
>> C = regexp(S,'\d+','match');
>> C{:}
ans =
'24' '500'
ans =
'80' '500'
ans =
'80' '700'