// 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)^\s*(\w*)=\s?\d").unwrap();
let string = "#!/bin/bash
flavor=${1:-dzen2}
function gmail() {
while true
do
inbox_count=$(wget -q -O- --auth-no-challenge --user=something@gmail.com --password=something 'https://mail.goog$
echo \"Gg:$inbox_count\"
sleep 60
done
}
function weather() {
while true
do
weather_stat=$($HOME/.config/i3/./weather.sh)
echo \"F$weather_stat\"
sleep 900
done
}
function time_date() {
while true
do
klocka=$(date +'%A den %d %B v%V %H:%M')
echo \"S$klocka\"
sleep 10
done < <(echo)
}
bspc control --put-status
xtitle -sf \"T%s\" > \"$PANEL_FIFO\" &
weather > \"$PANEL_FIFO\" &
gmail > \"$PANEL_FIFO\" &
time_date > \"$PANEL_FIFO\" &
case \"$flavor\" in
bar)
cat \"$PANEL_FIFO\" | .config/bspwm/panel_bar | bar
;;
dzen2)
. .config/bspwm/panel_colors
PANEL_HEIGHT=14
FONT_FAMILY='Dejavu Sans'
FONT_SIZE=9
cat \"$PANEL_FIFO\" | .config/bspwm/panel_dzen2 -f \"$FONT_FAMILY\" -s \"$FONT_SIZE\" | \\
dzen2 -h $PANEL_HEIGHT -dock -ta l -title-name panel -fn \"${FONT_FAMILY}:pixelsize=${FONT_SIZE}\" \\
-fg \"$COLOR_FOREGROUND\" -bg \"$COLOR_BACKGROUND\"
;;
esac";
// 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/