1

Im trying to match everything for the E) "column".

A1147/13 NOTAMN
Q) ESAA/QRRCH/IV/BO /AW/000/023/5933N01746E002
A) ESSA B) 1311140900 C) 1311211500
D) 14 21 0900-1500
E) UPPER LIMIT ES R16C KUNGSANGEN RAISED TO 2300 FT AMSL
REF AIP ENR 5.1
F) GND G) 2300FT AMSL
CREATED: 30 Oct 2013 10:00:00 
SOURCE: EUECYIYN

Using the following regex:

preg_match_all('/E\)(.*)(?=F\))/is', $string, $output);

I have managed to get the data, but only as long as the F) column exists, which it doesnt always do. Sometimes it ends just like:

A1147/13 NOTAMN
Q) ESAA/QRRCH/IV/BO /AW/000/023/5933N01746E002
A) ESSA B) 1311140900 C) 1311211500
D) 14 21 0900-1500
E) UPPER LIMIT ES R16C KUNGSANGEN RAISED TO 2300 FT AMSL
REF AIP ENR 5.1
CREATED: 30 Oct 2013 10:00:00 
SOURCE: EUECYIYN

How to solve this?


Edit: This is the part that i want to return:

UPPER LIMIT ES R16C KUNGSANGEN RAISED TO 2300 FT AMSL
REF AIP ENR 5.1

It will either end with the start of column F) or the text CREATED.

0

2 Answers 2

2

I would suggest using HamZa's method, with a little other tweak:

E\)(.*?)(?=F\)|$)

regex101 demo

You might also try something like this, though it can be a little longer to process:

E\)((?:(?!F\)).)+)

regex101 demo

(?:(?!F\)).)+ will match anything except F)

If you want to match until CREATED:, you can easily add it to the regex:

E\)((?:(?!F\)|CREATED:).)+)
Sign up to request clarification or add additional context in comments.

1 Comment

The last part solved it! Great demo site, i didn't know about that one! :)
1

Don't use DOTALL and use MULTILINE:

/^E\).*$/im

3 Comments

@HamZa: It did work in your demo by matching: E) UPPER LIMIT ES R16C KUNGSANGEN RAISED TO 2300 FT AMSL
Hmmm it's not clear in the question, but I interpreted it as to match until SOURCE: EUECYIYN -- I could be wrong
@HamZa: I may be wrong but as per Im trying to match everything for the E) "column". I interpreted as full line starting from E)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.