String Functions - Returns a specified segment from a string

7 - Meteor

Issue - Need help in string function to be used

Sample data

Case -1  : 66-YY-ZZZZ-AAAAAA-123
Case -2 : MX-YY-AAAA-ZZZZZZ-596
Case -3 : 66|YYYYYYY|ZZZZZZZZ|AAAAAAAAA|1|12|11234|X



I need to extract "AAAAAA" from Case-1 , "AAAA" from case-2 and "AAAAAAAA" from case-3. This is the mix of the data I have in my file


in other languages we can extract the 4th segment from case-1 after the '-' , 3rd segment from case-2 after '-' and in case 3, 4th segment after '|'.


How do i replicate it in Alteryx.