java - how do I extract characters consecutive to the substring and the substring itself After checking if string array contains the required substring -
im trying deal following string array called "wifis":-
[ssid: stephen joseph, bssid: ##:a6:##:c0:21:##, capabilities: [wpa2-psk-ccmp][wps][ess], level: -78, frequency: 2442, timestamp: 998653673499, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tp-link_g6d356, bssid: 30:b5:c2:f5:$$:56, capabilities: [wpa-psk-ccmp][wpa2-psk-ccmp][wps][ess], level: -86, frequency: 2452, timestamp: !!!653673417, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: cbtap998852211c:cf:7f:0a:ac:33, bssid: 5e:cf:7f:0a:ac:91, capabilities: [ess], level: -46, frequency: 2412, timestamp: 238653673402, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tech_d0008214, bssid: 70:5a:9e:65:30:56, capabilities: [wpa-psk-ccmp+tkip][wpa2-psk-ccmp+tkip][ess], level: -88, frequency: 2462, timestamp: 238653673422, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tech_d0018138, bssid: 50:09:59:83:ee:05, capabilities: [wpa-psk-ccmp+tkip][wpa2-psk-ccmp+tkip][ess], level: -91, frequency: 2437, timestamp: 238653673427, hs2info: <none>, distance: ?(cm), distancesd: ?(cm)]
and wish check , extract cbtap998852211c:cf:7f:0a:ac:33
, separate out cbtap
as string, 99885221
bcz dynamic 8 digit , rest 1c:cf:7f:0a:ac:33
string.
and bssid number 5e:cf:7f:0a:ac:91
above string array. check have done if(arrays.aslist(wifis).contains(confirmation)){
confirmation cbtap
how extract , the above mentioned tasks.please suggest apprach.
when break string, must use key find first part. assumed tbtap key.
note ip has 6 parts, not 5 wrote.
string s = "[ssid: stephen joseph, bssid: ##:a6:##:c0:21:##, capabilities: [wpa2-psk-ccmp][wps][ess], level: -78, frequency: 2442, timestamp: 998653673499, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tp-link_g6d356, bssid: 30:b5:c2:f5:$$:56, capabilities: [wpa-psk-ccmp][wpa2-psk-ccmp][wps][ess], level: -86, frequency: 2452, timestamp: !!!653673417, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: cbtap998852211c:cf:7f:0a:ac:33, bssid: 5e:cf:7f:0a:ac:91, capabilities: [ess], level: -46, frequency: 2412, timestamp: 238653673402, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tech_d0008214, bssid: 70:5a:9e:65:30:56, capabilities: [wpa-psk-ccmp+tkip][wpa2-psk-ccmp+tkip][ess], level: -88, frequency: 2462, timestamp: 238653673422, hs2info: <none>, distance: ?(cm), distancesd: ?(cm), ssid: tech_d0018138, bssid: 50:09:59:83:ee:05, capabilities: [wpa-psk-ccmp+tkip][wpa2-psk-ccmp+tkip][ess], level: -91, frequency: 2437, timestamp: 238653673427, hs2info: <none>, distance: ?(cm), distancesd: ?(cm)]"; int idx = s.indexof("cbtap"); // cbtap998852211c:cf:7f:0a:ac:33, if (idx != -1) { int idx2 = s.indexof(',',idx); s = s.substring(idx,idx2); string cbtap = s.substring(0,5); idx = s.indexof(':'); string id = s.substring(5,idx-2); string ip = s.substring(idx-2); system.out.println(cbtap+" / "+id+" / "+ip); }
Comments
Post a Comment