Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>import re names = ['g18_84pp_2A_MVP1_GoodiesT0-HKJ-DFG_MIX-CMVP1_Y1000-MIX.txt', 'g18_84pp_2A_MVP2_GoodiesT0-HKJ-DFG_MIX-CMVP2_Y1000-MIX.txt', 'g18_84pp_2A_MVP3_GoodiesT0-HKJ-DFG_MIX-CMVP3_Y1000-MIX.txt', 'g18_84pp_2A_MVP4_GoodiesT0-HKJ-DFG_MIX-CMVP4_Y1000-MIX.txt', 'g18_84pp_2A_MVP5_GoodiesT0-HKJ-DFG_MIX-CMVP5_Y1000-MIX.txt', 'g18_84pp_2A_MVP6_GoodiesT0-HKJ-DFG_MIX-CMVP6_Y1000-MIX.txt', 'g18_84pp_2A_MVP7_GoodiesT0-HKJ-DFG_MIX-CMVP7_Y1000-MIX.txt'] f = lambda x: re.findall('g18_84pp_2A_MVP(.*?)_GoodiesT0(.*?)_MIX(.*?)\.txt', x) for x in names: print(f(x)) </code></pre> <p>Produces</p> <pre><code>[('1', '-HKJ-DFG', '-CMVP1_Y1000-MIX')] [('2', '-HKJ-DFG', '-CMVP2_Y1000-MIX')] [('3', '-HKJ-DFG', '-CMVP3_Y1000-MIX')] [('4', '-HKJ-DFG', '-CMVP4_Y1000-MIX')] [('5', '-HKJ-DFG', '-CMVP5_Y1000-MIX')] [('6', '-HKJ-DFG', '-CMVP6_Y1000-MIX')] [('7', '-HKJ-DFG', '-CMVP7_Y1000-MIX')] </code></pre> <p>Filter the names that doesn't match this pattern:</p> <pre><code>names = list(filter(f, names)) </code></pre> <p>Since it's unclear what you're trying to do, this is going to be a good starting point.</p> <p><strong>UPDATE</strong></p> <p>The question was updated. Here is what you (probably) want to achieve:</p> <pre><code>import re names = ['g18_84pp_2A_MVP1_GoodiesT0-HKJ-DFG_MIX-CMVP1_Y1000-MIX.txt', 'g18_84pp_2A_MVP2_GoodiesT0-HKJ-DFG_MIX-CMVP2_Y1000-MIX.txt', 'g18_84pp_2A_MVP3_GoodiesT0-HKJ-DFG_MIX-CMVP3_Y1000-MIX.txt', 'g18_84pp_2A_MVP4_GoodiesT0-HKJ-DFG_MIX-CMVP4_Y1000-MIX.txt', 'g18_84pp_2A_MVP5_GoodiesT0-HKJ-DFG_MIX-CMVP5_Y1000-MIX.txt', 'g18_84pp_2A_MVP6_GoodiesT0-HKJ-DFG_MIX-CMVP6_Y1000-MIX.txt', 'g18_84pp_2A_MVP7_GoodiesT0-HKJ-DFG_MIX-CMVP7_Y1000-MIX.txt'] expression = 'g18_84pp_2A_MVP(.*?)_Goodies(.*?)_MIX(.*?)\.txt' f = lambda x: re.findall(expression, x) _f = lambda x: len(re.findall(expression, x))==3 for x in names: print(f(x)) </code></pre> <p>Outputs</p> <pre><code>[('1', 'T0-HKJ-DFG', '-CMVP1_Y1000-MIX')] [('2', 'T0-HKJ-DFG', '-CMVP2_Y1000-MIX')] [('3', 'T0-HKJ-DFG', '-CMVP3_Y1000-MIX')] [('4', 'T0-HKJ-DFG', '-CMVP4_Y1000-MIX')] [('5', 'T0-HKJ-DFG', '-CMVP5_Y1000-MIX')] [('6', 'T0-HKJ-DFG', '-CMVP6_Y1000-MIX')] [('7', 'T0-HKJ-DFG', '-CMVP7_Y1000-MIX')] </code></pre> <p>If you need to filter the original list:</p> <pre><code>names = list(filter(_f, names)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload