Extract value until regexp case match
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have this string. I was hoping to use regexp in order to extract the time and date embedded in this string. I was going to use regexp '.*?<=216', as prior to 216 is all the values I was hoping to extract. I was hoping that there would be an easy way to extract the date and time to a separate cell array. Thanks for any and all help.
"9/12/2022 7:38:51 PM
216 Indicator"
2 Commenti
Rik
il 23 Set 2022
While this could work, is there a reason why you can't match the date itself directly?
Risposta accettata
Stephen23
il 23 Set 2022
Does the data you want to match always occur at the start of the string?
A = "9/12/2022 7:38:51 PM 216 Indicator";
B = regexp(A,'^\S+\s+\S+\s[AP]M','match','once')
T = datetime(B,'inputFormat','d/M/u h:m:s aa')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!