Is there a means to return the pattern found from within an input variable, with the possible addition of highlighting the pattern within the variable? (e.g. for Regex, returning the input variable with the pattern found)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
While your question is a bit unclear, it sounds like you would like to merely highlight or mark in some form or fashion a substring (or perhaps a pattern) of a larger string. There are many ways to go about this, depending especially on the substring/pattern you’d like to search, but here’s a simple example:
Of course this merely replaces the pattern with a modified version, returning the full string. Other functions, like
preg_matchorpreg_match_allcan return an array of the matched patterns. Again, it all depends on what your precise needs are.