Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to use regexp with a string correctly

1 次查看(过去 30 天)
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.

回答(1 个)

Star Strider
Star Strider 2017-2-2
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'

标签

Community Treasure Hunt

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

Start Hunting!

Translated by