I have thousands of strings arranged in following manner:
>String1 \(sub1|string1)
DIMMFIOYBVSYBE
EFMWUISCFIUBFMCIUOEFMIUIDEM
>String2 \(sub2|string2)
HVUYVMUYBOIIUMYTVU
SYOYVSCOUYCVUYVSUYVUSC
I want to extract some substrings based on certain conditions, such that the following substrings should be extracted. The substrings will be:
String1:
DIM X
M X
FIOYBVS
YBEEFM
WUISC X
FIUBFMC X
IUOEFM
IUIDEM
String2:
HVUYVM
UYBOIIUM
YTVUS
YOYVSC X
OUYCVUYVS X
UYVUSC X
The conditions are:
- substring should end with either
MorS MorSshould not be succeeded byC- Length of the substring should be
≥ 4and≤ 8charters
In the above example list of substring the marked X will not be considered as they don't follow the criteria.
Expected output:
Name Frequency substrings
String1 4 FIOYBVS; YBEEFM; IUOEFM; IUIDEM
String2 3 HVUYVM; UYBOIIUM; YTVUS
I tried using the sliding window method mentioned here. It does not work for me. Any help appreciated.