I would like to use Ruby's sub(pattern, replacement) for removing a line of the form last-lrm-refresh=<value> from a multi-line substring. Here is an example of the entire string:
maintenance-mode=true \
last-lrm-refresh=1523448810 \
no-quorum-policy=stop
The following does not quite work:
s.sub(' \\\n[ \t]+last-lrm-refresh=[0-9]+', '')
When I try the same regular expression in an interactive regular expression editor (such as Rubular) it works fine, so I guess the problem is about escaping characters.
What is the right form of regular expression to pass a string into sub to achieve the desired effect? I've tried a few "permutations" but without success so far. (I've also tried something similar with Perl before.)
s.sub(/ \\\n[ \t]+last-lrm-refresh=[0-9]+/, '')- use a regex, not a literal string substitution.' \\\n[ \t]+last-lrm-refresh=[0-9]+'is not a regular expression. It's a string.