Enryu Enryu - 11 months ago 33
Javascript Question

Match only if conditions are true

I'd like to get help with making a Regex match in JavaScript

Match only:

  • If the row (Odd) has a number larger than 25 AND the row
    (Even) has the word "Apples" in it.

    • Explanation:

      • The first row's value (29) belongs to the second row ("First | Cocoa Apples are")

      • The third row's value (23) to the fourth row ("Second | Test Text") ... and so on...

The TEXT I will be using it with:

29% OK
First | Cocoa Apples are
23% NOT
Second | Test Text
18% NOT
Third | Mango Alpa Tango
16% NOT
Fourth | Apples are
33% OK
Fifth | Text Testing App
10% NOT
Sixth | Apples are Gold Duck
28% OK
Seventh | Alpa Apples are Tango
66% OK
Eighth | Oh My Apples are Avocado
20% NOT
Ninth | This Is My Text
25% NOT
Tenth | This Is Hard

Answer Source

Try this: