Hi i am trying to match two value by regex two conditions, But not able to do.
string is
MorText "gets(183,);inc();" for="text">Sweet" Mo
output trying is array
[
183,
"Sweet"
]
php regex code is
preg_match_all('/gets((.*?),|>(.*?)"/', $string, $matches);
2
Answers
If I understand correctly, you want to match two values from the string "gets(183,);inc();" for="text">Sweet" using regular expressions. Here’s an example regex that should work:
This regex has two capture groups:
Here’s an example PHP code to use this regex and extract the values:
This code will output:
To achieve your wanted output you can use:
PHP-Example:
Outputs: