Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    This is not very clear. (1) Please say, early in the question, what two patterns you are looking for.  (OK, on reading the question for the third time, I see that you talk about “the Virtual or Redirect lines”, so I guess that the patterns you are looking for are “Virtual” and “Redirect”.)  (2) I was going to say that “but only if the two patterns are consecutive, exclusive of any other strings between them” was also unclear, but I see that you eventually got around to explaining it.  (3) “ServerName web1.domain.com” appears twice in your input data.  This is confusing. Commented Aug 20, 2024 at 4:32
  • 1
    What does the not preformatted file look like? IMHO, giving you a way to work with the original data would help in various ways: a known parser of the data format could be used (if the data is in a well-known format), and you would end up with less handcrafted code to maintain. Commented Aug 20, 2024 at 5:50
  • 1
    Based on what I know about Apache configs, I'd expect the original file has some lines that aren't too relevant here. There would be end tags for the virtual hosts, but I don't think they're too useful either since the starting tags are enough to know where one ends and the next one starts. Commented Aug 20, 2024 at 9:23
  • @G-ManSays'ReinstateMonica' ServerName web1.domain.com does in fact appear twice in the file, which is why I included it. This file is an amalgamation of several Apache conf files because I need to combine them all and isolate redirected domains regardless if they appear in more than one conf and may not be redirected in all confs. Commented Aug 20, 2024 at 17:44
  • @Kusalananda The source files are standard Apache VHost configurations. However I need the list created from several combined files where the domain may be configured (ie, seperate Vhost and SSLhost confs) and from across multiple clusters. Commented Aug 20, 2024 at 17:49