-1

Hello i have another regex problem..

i have following text

Liquor
Liquor-Aussehen klar entf. entf. entf. entf. entf.
+
Leukozyten im Liquor < 5 /µl 6 entf. entf. entf. entf. entf.
Erythrozyten im Liquor 0 /µl 1 entf. entf. entf. entf. entf.
Mononukleäre Zellen i.L. - 100 % 0 entf. entf. entf. entf. entf.
Polymorphkernige Zell i. 0 % + 100 entf. entf. entf. entf. entf.
+ + - -
Glucose im Liquor 40 - 70 mg/dl 71 80 66 26 26 66
Lactat im Liquor < 2.1 mmol/l 1.5 1.6 1.7 ++ 5.1 ++ 5.1 1.7
Gesamt-Eiweiß im Liquor mg/dl entf. entf. entf. entf. entf. entf.
IgA im Liquor < 5 mg/l 3.20 4.01 ++ 17.00 + 10.00 + 10.00 ++ 17.00
IgG im Liquor < 34 mg/l + 53.00 + 57.60 + 97.00 + 65.00 + 65.00 + 97.00
IgM im Liquor < 1.34 mg/l + 1.40 + 1.82 ++ 8.00 ++ 4.50 ++ 4.50 ++ 8.00
Albumin im Liquor < 350 mg/l + 460.0 + 441.0 + 980.0 + 720.0 + 720.0 + 980.0

the first Liquor is the head of the document.. And i need to find this one. But if i look just for "Liquor" the regex will match the ones in Glucose im Liquor f.e. as well..

i build following regex because i think this negative lookahead will do the thing but

Liquor(?!-\s?[a-zA-Z<>+-0-9]?)

still matches the other ones.. How can i exclude the Liquors that doesnt stand alone. Liquors that can be followed by a number, letter or lower than or higher than signs shouldn be matched..

Is there any Solution?

Michael
  • 39
  • 6
  • 1
    Use end string ancor `$` maybe? Would that suffice? > `^Liquor$` – JvdV Mar 02 '20 at 07:51
  • Please share your related code to see how you handle the string. What are trying to achieve? I doubt you want to extract a known word. – Wiktor Stribiżew Mar 02 '20 at 08:28
  • Do you only want the head/title or the word "Liqour" which stands alone in a line? – kame Mar 02 '20 at 09:36
  • yes, i want only the standalone word "Liquor", but the text can also look like i have shown in my other comment : "\nLiquor\nLiquor-Aussehen klar entf. entf. entf. entf. entf.\n+\nLeukozyten im Liquor[...]" – Michael Mar 02 '20 at 09:54

1 Answers1

0

If you just want Liquor line, then match ^Liquor$

Or if you want a line that ends with Liquor then use Liquor$

BTW, in all your other lines with Liquor (except the 2nd one), the word is followed by a space (this is why the negative lookahead returns true every time : - cannot match a space)

David Amar
  • 247
  • 1
  • 5
  • Yea that worked for the text above but in furher test and other textes i recognized that the regex didnt match the word when it looks like this "\nLiquor\nLiquor-Aussehen klar entf. entf. entf. entf. entf.\n+\nLeukozyten im Liquor[...]" where i need the first Liquor – Michael Mar 02 '20 at 09:01