Re: [pcre-dev] Matching file contents as one string using PC…

Αρχική Σελίδα
Delete this message
Συντάκτης: Zoltán Herczeg
Ημερομηνία:  
Προς: pcre-dev
Αντικείμενο: Re: [pcre-dev] Matching file contents as one string using PCRE_DOTALL
Hi,

dot (.) is the inverse of \R.

If you need to match everything, use [\x00-\xff] or (.|\R) or \p{Any} (the latter only if unicode is enabled). I would choose the first for ascii, and the third for unicode matches.

Regards,
Zoltan

pcunite@??? írta:
>I have read the entire PCRE documentation and have not found something that>

states clearly what I'm looking to do. The documentation says: "By default,>
PCRE treats the subject string as consisting of a single line of characters>
(even if it actually contains newlines)." That is what I want to hear, but it>
is not working out in practice. Testing version 8.32.>
>

Goals:>
1. Load a text file into a std::wstring buffer.>
2. Have no regard for the concept of "lines". One big string is fine.>
3. Use Positive Lookahead to find terms in ANY order.>
4. I don't ever care about capturing or using LookBehinds.>
5. Any character before or after the query terms is fine.>
>

Regex: >
Thus I have come up with this: (?=.*hello.*)(?=.*world.*)>
>

Sample data from file.txt:>
First line, hello present.>
Second with world present.>
>

Please verify this Solution:>
However, it only seems to work if I set PCRE_DOTALL. What are the consequences of>
using this flag? Is there a better way? I don't really want to use the ^$ combo as>
that is the notion of lines, no? They don't work anyway.>
>
>
>

-- >
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev >