1
preg_match("/Designer:(.*?)|Created by:(.*?)\n/i",$sitesource,$designer);

Hi, Can anyone tell me how can I perform multiple searches? For example, if the "designer" keyword not found, then search for "created by" and so on

0

1 Answer 1

1

You can use

preg_match_all("/(?:Created by|Designer):(.*)/i", $sitesource, $designer);

That is, use preg_match_all to match multiple occurrences and merge the two alternatives into a simpler (?:Created by|Designer):(.*) that means

  • (?:Created by|Designer) - either Created by or Designer
  • : - a colon
  • (.*) - capturing group #1: the rest of the line.

See the regex demo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.