Avatar of EMB01
EMB01
Flag for United States of America asked on

Regex for String

In the following string I would like to get the following:

Get this:

Business Machine.\nCombustion.\nFuel Cell.\nIndustrial.\nMedical.\nTransit.\nAquaculture.\nOther.

From this:

string(264) "required=0 changeable=0 show_at_reg_form=0 show_at_my_details_form=0 show_at_userlist_profile=0 show_at_userlist_card=0 values=Business Machine.\nCombustion.\nFuel Cell.\nIndustrial.\nMedical.\nTransit.\nAquaculture.\nOther. default_values= searcheable=1 cols=20 " 
<?php
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);
?>

Open in new window

Thank you.
PHPRegular Expressions

Avatar of undefined
Last Comment
EMB01

8/22/2022 - Mon
SOLUTION
Chris Harte

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
EMB01

ASKER
I didn't test the non-regex solution, but the regex worked, thanks.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23