$re = '/PLF2/m';
$str = 'import React from \'react\';
import { useState } from \'react\';
export default function UserForm() {
const [students, setStudents] = useState([
{ id: 1, name: \'Anna\', age: 18 },
{ id: 2, name: \'Tom\', age: 17 },
]);
const [name, setName] = useState(\'\');
const [age, setAge] = useState(0);
const handleSubmit = (event) => {
event.preventDefault();
};
const newStudent = {
id: Date.now(),
name: name,
age: age,
};
setStudents([...students, newStudent]);
setName(\'\');
setAge(0);
return (
<div>
<ul>
{students.map((student) => (
<li key={student.id}>
{student.name}
{student.age}
</li>
))}
</ul>
<form onSubmit={handleSubmit}>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<input
type="number"
value={age}
onChange={(e) => setAge(e.target.value)}
/>
<button type="submit"> Hinzufügen</button>
</form>
;
</div>
);
}
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php