Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to use regexp with a string correctly

1 visualización (últimos 30 días)
John Mayfield
John Mayfield el 2 de Feb. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
flag = 'KLAX 312353Z 27009KT 10SM FEW200 18/10 A3007 RMK AO2 SLP182 T01780100 10217 20178 55007'
I need to find extract 312352Z from the string using I tried regexp(flag, '\d{4}\Z', 'match');
I am sure the syntax is not correct. What is the correct syntax? Thanks in advance.

Respuestas (1)

Star Strider
Star Strider el 2 de Feb. de 2017
You need to tell regexp that you’re looking for the beginning and ending of a particular word:
wx_time = regexp(flag, '\<\d*Z\>', 'match')
wx_time =
cell
'312353Z'

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by