Regex match everything after comma within quotes

After your comment , will this be to your satisfaction?
Oke how about we ditch the group and simply state this:

$inputString = 'Here is some text bla bla dsa="123,45" and some more text here bla bla';
$regex = '/dsa=\x22\d+,(\d+)/';
$matches = [];
  • dsa=\x22: This part matches the literal string “dsa=”
  • \x22: This represents the double quote character “
  • \d+,: This matches one or more digits followed by a comma.

So after that we have the “behind” in form of a capture group:

  • (\d+): And this is your 1 to more digits capture group

This updated one shows no error in regex101.com/
1st time ever someone stated that a request to me 😀

Oke, last try with complete php code:

<?php
$inputString = 'Some text dsa="1,45" more text';
$regex = '/dsa=\x22(\d)\d+,(\d+)/';
$matches = [];

if (preg_match($regex, $inputString, $matches)) {
    $firstNumber = $matches[1];
    $secondNumber = $matches[2];
    echo "$firstNumber $secondNumber"; // Output: 1 45
} else {
    echo "No match found";
}

?>

1st we find dsa=” then we got capture group for 1 digit and then another one after rest of the digits preceeding , and the character ,

we glue those into 1 45

Read more here: Source link