what does the following regular expression mean (?s) .*? <h1>(.*?)</h1> its used to extarct matches from html

what does the following regular expression mean (?s) .*? <h1>(.*?)</h1> its used to extarct matches from html

Any ideas?

thanks
mmalik15Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmickCommented:
Posix based interpretation:
(?s)  matches anything that ends with an s followed by a space, any single character, followed by zero or more of the preceeding character, followed by a space followed by a space, the <h1> tag (case is important) followed by any single character, that repeats zero or more times with the final character matched exactly zero or one time followed by the </h1> tag.  The items in parentheses can be used in replacement expressions with (1) referring to the first group matched in parentheses and (2) referring to the second.
point_pleasantCommented:
(?s) .*? <h1>(.*?)</h1>

*? (lazy star) Repeats the previous item zero or more times, so in this case will match any test leading up to the <h1> heading then any omount of thext inside the <h1> up until the </h1> tag is reached. Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item.
käµfm³d 👽Commented:
(?s)  matches anything that ends with an s followed by a space

Actually, turns on single-line mode, where dot matches newline.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

mmalik15Author Commented:
Thanks for all the comments.

kaufmed thanks for clearing (?s)       :)

The regular expression is used to get any text between<h1> tags but i still did not understand why leading .*? was needed before <h1>
käµfm³d 👽Commented:
i still did not understand why leading .*? was needed before <h1>
I wouldn't think it would be. Does it fail without it?
mmalik15Author Commented:
thats what i thought and yeah it works fine without it
mmalik15Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.