I wish to extract the relevant string out from the below:
Signals =[
/'Signals'/'Panel_04_Outputs_BT_1753_2_[_TC_-_Type_T][](Tair_evap_HVAC_TC2_degC)'
6 /'Signals'/'LIN_1_Outputs_EAC_speed[](CompSpeed_rpm)'
7 /'Signals'/'Panel_01_Outputs_BT_1747_[PT100][](Tref_HX3_out_degC)'
8 /'Signals'/'AC_HVAC_Outputs_BM_1406[](Rhair_HVACunit_feed_perc)'
9 /'Signals'/'Panel_01_Outputs_BP_1741_[4-20mA][](Pref_SOV22_in_bar)'
10 /'Signals'/'Conditioning_Unit_9_Outputs_BT_XX31[](Tw_heater_core_out_degC)'
11 /'Signals'/'Panel_04_Outputs_BT_1754_2_[_TC_-_Type_T][](Tair_heater_HVAC_TC1_degC)'
12 /'Signals'/'Panel_01_Outputs_BP_1744_[4-20mA][](Pref_accum_in_bar)'
13 /'Signals'/'Panel_01_Outputs_BT_1236_[PT100][](Tref_TXVchiller_out_degC)'
14 /'Signals'/'Panel_01_Outputs_BT_1748_[PT100][](Tref_comp_out_degC)'
15 /'Signals'/'Panel_01_Outputs_BT_1248_[PT100][](Tref_TXV_in_degC)'
16 /'Signals'/'AC_HVAC_Outputs_BT_1402[](Tair_HVACunit_return_degC)'
17 /'Signals'/'Conditioning_Unit_9_Outputs_BT_XX34[](Tw_heater_core_in_degC)'
18 /'Signals'/'Panel_06_Outputs_XG_1818_[Counter][](Flowref_hybrid_chiller_in_)'
19 /'Signals'/'Panel_06_Outputs_XG_1817_[Counter][](Flowref_Cab_evap_in_)'
20 /'Signals'/'Conditioning_Unit_3_Outputs_BF_XX27[](Flow_water_hybrid_cond_lpm)'
21 /'Signals'/'Panel_01_Outputs_BP_1249_[4-20mA][](Pref_TXV_in_bar)'
22 /'Signals'/'Panel_01_Outputs_BT_1746_[PT100][](Tref_SOV22_in_degC)'
23 /'Signals'/'AC_Battery_Outputs_BT_1506[](Tair_testcham_feed_degC)'
]
We can see some patterns in the string, for example for Row 10, I need to extract out:
Conditioning_Unit_9_Outputs_BT_XX31
and for Row 11, I need to extract out:
Panel_04_Outputs_BT_1754_2_[TC-_Type_T]
So the pattern before is "/'Signals'/'" and the pattern after is "".
I tried the code below:
res <- str_match(Signals[10,], "Signals\s*(.?)\s(")
Error in stri_match_first_regex(string, pattern, opts_regex = opts(pattern)) :
Missing closing bracket on a bracket expression. (U_REGEX_MISSING_CLOSE_BRACKET, context=Signals\s*(.*?)\s*[](
)
res <- str_match(Signals[10,], "Signals\s*(.?)\s(")
Error: '[' is an unrecognized escape in character string starting ""Signals\s*(.?)\s["
The pattern after is the two square brackets.
Thanks.