Re: Reading .txt File into String and Matching with RegEx

2023-12-11 Thread BoQsc via Digitalmars-d-learn
Matches function declarations and captures function names from `.d` Source Code file **regexcapture.d** ``` import std.stdio : writeln; import std.regex : matchAll, regex; import std.file : read; void main(){ string input = cast(string)read("sourcecode.d"); foreach(match;

Re: Reading .txt File into String and Matching with RegEx

2023-12-11 Thread BoQsc via Digitalmars-d-learn
On Monday, 11 December 2023 at 05:18:45 UTC, thinkunix wrote: BoQsc via Digitalmars-d-learn wrote: This is something I've searched on the forum and couldn't find exact answer. TLDR: `r"^."` is matching the very first two character in the `input` string. Don't you need two dots to match two

Re: Reading .txt File into String and Matching with RegEx

2023-12-10 Thread thinkunix via Digitalmars-d-learn
BoQsc via Digitalmars-d-learn wrote: This is something I've searched on the forum and couldn't find exact answer. TLDR: `r"^."` is matching the very first two character in the `input` string. Don't you need two dots to match two characters? Each dot being the regex to match a single

Reading .txt File into String and Matching with RegEx

2023-12-10 Thread BoQsc via Digitalmars-d-learn
This is something I've searched on the forum and couldn't find exact answer. TLDR: `r"^."` is matching the very first two character in the `input` string. **matchtest.d** ``` import std.stdio : writeln; import std.regex : matchAll; import std.file : read; void main(){ string input