Hi I have the following string:
e-bgp-ip@2016-03-21.y:688: error: bad value "redi-bfg" (should be if-feat-ex)
I need to match the string with a regex. However the string can be hyphenated and non-hyphenated so it can also be
e-bgp-ip@2016-03-21.y:688: error: bad value "redibfg" (should be if-feat-ex)
I can catch the non-hyphenated version with
/^.*? error: bad value \"\w+\" \(should be *.*$/m
I'm trying to replace any line this regex matches, heres an example I have for a different line:
$line = preg_replace('/^.*? key \"\w+\" not in order, *.*$/m', '', $line);
However I need a regex that can catch both the first example and the second example, anyone have any ideas how I can do this?
Just replace \w
by a character class that includes the dash: [\w-]
$line = preg_replace('/^.*? key "[\w-]+" not in order, *.*$/m', '', $line);