There is a text:

Bla-Bla ERROR An error occurred while attempting to deploy the job 

There is a regular expression:

 ^ERROR(.+) 

In the program, as well as on the site regexr.com, the last line is not taken! But as soon as you remove the start line character in a regular expression, ^ - then everything works. Why? In the text there is a line break (10th ASCII character). Checked here .

    1 answer 1

    In order for the ^ and $ characters to work for multiline text, you need to specify the Multiline modifier: /^ERROR(.+)/m / /^ERROR(.+)/m

    I recommend checking here: https://regex101.com/

     /^ERROR(.+)/m ^ assert position at start of a line ERROR matches the characters ERROR literally (case sensitive) 1st Capturing group (.+) .+ matches any character (except newline) Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy] m modifier: multi-line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)