-3

I have a little problem. I want to find words "dataLayer" and "rating" in this text :

script> dataLayer = [{ 'category': 'Lifestyle', 'rating' : 'U', 'unused' : 'No', 'adult' : 'No', 'pda' : 'No', 'hasAds' : 'No', 'lang' : 'en' }];

I was trying with dataLayer[^r]* but its stack in word"category". Even if i add "rating" in square brackets it doesn't help.

Help!

10
  • 2
    Regex is not what you want here.
    – Maroun
    Dec 17, 2014 at 12:57
  • Do you mean you need to get all the words in between dataLayer and rating?
    – SMA
    Dec 17, 2014 at 12:58
  • I have task to do it with regex. Dec 17, 2014 at 12:59
  • @TomszComasz How does this have to do with C? Dec 17, 2014 at 13:00
  • I i need to find "rating" but i put here only fragment of big text so, first need have to find "dataLayer" who precedens "rating" Dec 17, 2014 at 13:02

1 Answer 1

0

You can use this regex:

(\bdataLayer\b.*?\brating\b)

Online demo

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.