Extracting information with Regex between two words in a line

I have a text line like this:
Espacio aéreo: ATZ GCXO Clase: D

I want to extract the text between “Espacio aéreo:” and “Clase”.

I tried with this Pattern in Regex “(?<=aéreo:\s*)([^hz]*)(?<=Clase)”. However, it doesn’t work and I need some help.
Thanks.

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=aéreo:\s*)([^hz]*)(?=Clase)").Value

Regards,

HI Please try this

[^Espacio aéreo:]\w*[^Clase: D]

image

The thing is that I’m working with different and larger texts. In all of them, the words “Espacio aéreo:” and “Clase” remain in the same way. However, “ATZ GCXO” and “D” changes between texts. So, I want a Pattern that can extract the words between Espacio aéreo and Clase, ignoring the rest of words.
A part of this big text is, for instance:
Expediente
001/19

INCURSIÓN EN PISTA

Fecha del incidente
10/01/2019

  1. INFORMACIÓN DISPONIBLE PARA EL ANÁLISIS

 Extracto Desidentificado de Notificación de la Aeronave 1.
 Audios.
 Datos Radar.
 Información del AIP: AD 2 –GCXO -GMC.
 Informe RAT.

001/19 - Pág. 2 de 9

  1. UBICACIÓN DEL INCIDENTE

Fecha: 10/01/2019 Hora (UTC): 13:15

Notificado por: Aeronave 1 / Aeronave 2 / TWR GCXO / Aeropuerto Tenerife Norte

Condiciones meteorológicas: VMC

Espacio aéreo: ATZ GCXO Clase: D

Localización: RWY 30 de GCXO

Hi,
I try it but, the problem is that it doesn’t recognize the part of the text that I want. It’s a large text and, inside it, I want to extract with a Pattern everything that is between “Espacio aéreo:” and “Clase:”

Hi,

"(?<=aéreo:\s*).*?(?=Clase)" will basically work, i think.

Can you try the following sample?

Sample20210408-1.zip (2.7 KB)

Regards,

Hi,
It works, yeah! Thanks a lot.
And, I will appreciate if you can help me extracting another information.
In the longer text above, I want to extract the information “INCURSIÓN EN PISTA” which change between many texts that I’m working with. The thing is that before this information, “001/19” has always the same format “[01]…/1.” and the words after “Fecha del incidente” don’t change.
Therefore, I was trying to extract it with this Pattern “(?<=[01]…/1.\s*)[^Fecha]*(?=Fecha)”. However, it doesn’t work.

Hope you can help me, thanks!!

Hi,
Can you try the following pattern?

"(?<=[01]\d*/[19]\d*\s*).*?(?=\s*Fecha del incidente)"

Sample20210408-1v2.zip (2.8 KB)

Regards,

Hi,
it works, thanks!

1 Like