'How to use regex_search to get the a line of text from two different .txt files
I'm trying to use this regex pattern Subject: [\a-zA-Z_0-9]+ in c++ to get this line of text from two different files one being this:
Message-ID: <..>
Subject: AAAI-22 General Information
MIME-Version: 1.0
Content-Type: multipart/alternative; ..
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
and the other being
Subject: Re: Possible need for … 240
Thread-Topic: Possible need for printout for .. 240
however, the regex pattern matches:
Subject: AAAI-22 General Information MIME-Version: 1.0
Content-Type: multipart/alternative; ..Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
for the first text file and for the second file the pattern matches
Subject: Re: Possible need for
All I want my regex pattern to search for and print out is the Subject: and whatever else is in that line and nothing else. How can I do that using regex_search and regex_replace patterns?
Solution 1:[1]
You can use this regex pattern to search for Subject line
"Subject: .+"
Explanation:
Subject:matches the charactersSubject:literally (case sensitive)..matches any character (except for line terminators)+matches the previous token between one and unlimited times
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gajendragarg |
