MATLAB Answers

How to use regexp with a string correctly

1 view (last 30 days)
John Mayfield
John Mayfield on 2 Feb 2017
Answered: Star Strider on 2 Feb 2017
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.

  0 Comments

Sign in to comment.

Answers (1)

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

  0 Comments

Sign in to comment.

Tags


Translated by