// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)matei 140 for ").unwrap();
let string = "<?php
$days = 7; // Eine Woche
$activity = \"Laufen\"; // Trainingsart
$duration = 30; // Minuten pro Tag
for ($day = 1; $day <= $days; $day++) {
echo \"Am Tag $day bist du $duration Minuten $activity gewesen.<br>\";
}
$activities = [\"Laufen\", \"Schwimmen\", \"Radfahren\", \"Yoga\", \"Krafttraining\"];
$motivation = 5; // Skala 1-10
$goal = \"fit werden\"; // Ziel
$duration = 30; // Minuten pro Tag
$days = 7; // Eine Woche
for ($day = 1; $day <= $days; $day++) {
$activity = $activities[($day-1)%count($activities)];
echo \"<br>Tag $day: Heute machst du $duration Minuten $activity, Motivation: $motivation/10, Ziel: $goal.\";
$motivation++;
if($day == $days){
echo \"<br>\";
}
}
function wochenplan($activities, $days, $dauerProTag) {
$gesamt = 0;
for ($i = 1; $i <= $days; $i++) {
$activity = $activities[array_rand($activities)];
echo \"<br> Tag $i: $activity für $dauerProTag Minuten.\";
$gesamt += $dauerProTag;
if($i == $days){
echo \"<br><br>\";
}
}
return $gesamt;
}
$activities = [\"Laufen\", \"Schwimmen\", \"Radfahren\", \"Yoga\", \"Krafttraining\"];
$gesamt = wochenplan($activities, 7, 30);
echo \"Gesamtzeit: $gesamt Minuten.\";
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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 Rust, please visit: https://docs.rs/regex/latest/regex/