Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract the common words before particular symbol and find particular word
    text
    copied!<p>IF I have a dictionary:</p> <pre><code>mydict = {"g18_84pp_2A_MVP1_GoodiesT0-HKJ-DFG_MIX-CMVP1_Y1000-MIX.txt" : 0, "g18_84pp_2A_MVP2_GoodiesT0-HKJ-DFG_MIX-CMVP2_Y1000-MIX.txt" : 1, "g18_84pp_2A_MVP3_GoodiesT0-HKJ-DFG_MIX-CMVP3_Y1000-MIX.txt" : 2, "g18_84pp_2A_MVP4_GoodiesT0-HKJ-DFG_MIX-CMVP4_Y1000-MIX.txt" : 3, "g18_84pp_2A_MVP5_GoodiesT0-HKJ-DFG_MIX-CMVP5_Y1000-MIX.txt" : 4, "g18_84pp_2A_MVP6_GoodiesT0-HKJ-DFG_MIX-CMVP6_Y1000-MIX.txt" : 5, "h18_84pp_3A_MVP1_GoodiesT1-HKJ-DFG-CMVP1_Y1000-FIX.txt" : 6, "g18_84pp_2A_MVP7_GoodiesT0-HKJ-DFG_MIX-CMVP7_Y1000-MIX.txt" : 7, "h18_84pp_3A_MVP2_GoodiesT1-HKJ-DFG-CMVP2_Y1000-FIX.txt" : 8, "h18_84pp_3A_MVP3_GoodiesT1-HKJ-DFG-CMVP3_Y1000-FIX.txt" : 9, "p18_84pp_2B_MVP1_GoodiesT2-HKJ-DFG-CMVP3_Y1000-FIX.txt" : 10} </code></pre> <ol> <li><p>I want to extract the common part <code>g18_84pp_2A_MVP_GoodiesT0</code> before the first <code>-</code>. </p></li> <li><p>also I want add a <code>_MIX</code> to follow <code>g18_84pp_2A_MVP_GoodiesT0</code> when finding the particular word <code>MIX</code> in first group . Assume that I am able to classify two groups depending on whether is <code>MIX</code> or <code>FIX</code> in myDict, then the final Output dictionary:</p></li> </ol> <pre><code>OutputNameDict= {"g18_84pp_2A_MVP_GoodiesT0_MIX" : 0, "h18_84pp_3A_MVP_GoodiesT1_FIX" : 1, "p18_84pp_2B_MVP_FIX": 2} </code></pre> <p>Is there any function I could use to find common part? How pick up the word before or after particular symbol like <code>-</code> and find particular words like <code>MIX</code> or <code>FIX</code>?</p>
 

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