Search for permutation of characters of a substring in Python
问题 I am trying to extract the occurrences of a string and of all the permutations of its characters from a line of text. For example, I need to extract the string t = 'ABC' and all its permutations: 'ABC', 'CAB', 'BCA', 'BAC', 'CBA', from the following string s: s = 'ABCXABCXXACXXBACXXBCA' The results is: ABC , ABC , BAC , BCA The string t should be of any length and can contain any characters in [A-Z] , [a-z] and [0-9] Is there a way to obtain the result by using regular expressions in Python?