how to use perl regex to get n words before pattern?

shu

New member
for example, I want to get "a silly" from the sentence "This is a silly question" by the search keyword "question". I know I can use

/(\S+ \S+) question/

to get it, but what if I want to get 100 words before the matching pattern. I'm sure I don't want to type \S+ 100 times. I tried \S+{2}, but it doesn't work.

Thanks.
 
Back
Top