2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

fhem.pl: eventMap checks if regexp is word only to use \b. (Forum #207899)

git-svn-id: https://svn.fhem.de/fhem/trunk@6781 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-10-18 06:07:58 +00:00
parent 147406c02e
commit 56a8767a0f

View File

@ -3261,12 +3261,21 @@ ReplaceEventMap($$$)
foreach my $rv (@emList) { foreach my $rv (@emList) {
# Real-Event-Regexp:GivenName[:modifier] # Real-Event-Regexp:GivenName[:modifier]
my ($re, $val, $modifier) = split(":", $rv, 3); my ($re, $val, $modifier) = split(":", $rv, 3);
my $reIsWord = ($re =~ m/^\w*$/); # dim100% is not \w only, cant use \b
next if(!defined($val)); next if(!defined($val));
if($dir) { # event -> GivenName if($dir) { # event -> GivenName
if($str =~ m/\b$re\b/) { if($reIsWord) {
$str =~ s/\b$re\b/$val/; if($str =~ m/\b$re\b/) {
$changed = 1; $str =~ s/\b$re\b/$val/;
last; $changed = 1;
last;
}
} else {
if($str =~ m/$re/) {
$str =~ s/$re/$val/;
$changed = 1;
last;
}
} }
} else { # GivenName -> set command } else { # GivenName -> set command
@ -3274,6 +3283,12 @@ ReplaceEventMap($$$)
$nstr = $re; $nstr = $re;
$changed = 1; $changed = 1;
last; last;
} elsif($reIsWord) {
if($nstr =~ m/$val/) {
$nstr =~ s/$val/$re/;
$changed = 1;
last;
}
} elsif($nstr =~ m/\b$val\b/) { } elsif($nstr =~ m/\b$val\b/) {
$nstr =~ s/\b$val\b/$re/; $nstr =~ s/\b$val\b/$re/;
$changed = 1; $changed = 1;