0

For example I have the following file:

We have here a file
written as an example
for stack overflow
It has lettersA
It has numb3rs
And.Why.not some special, Characters'

I want to capture everything past the words stack overflow. I tried playing around in regex101 but my regex of /stack.?overflow(.)/g and /stack.?overflow(.)/gm is not returning anything and I'm just not sure where to go from here.

  • Possible duplicate of [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – revo Feb 08 '18 at 17:48
  • `.` doesn't match line breaks unless you have single line mode (`/s`) enabled. Also, you used a single dot with no quantifier, which will only match one character. – CAustin Feb 08 '18 at 18:08
  • Ah, I'm not sure why I didn't post the * after the . in my question but thank you. I was convinced that the multiline mode was to get multiple lines rather than the single line mode but looking more into their documentation it makes sense to me now. Thank you again. – ToastGhost Feb 09 '18 at 15:43

1 Answers1

0

Something like

(stack overflow.*)

would help, however you need to enable the . special character to include new lines. Your question does not specify a language but the (/s) modifier is the common modifier for this.

You then follow up the . with a * to say you want to match as many as you can.

Regexr
  • 56
  • 5