Code Monkey home page Code Monkey logo

Comments (7)

jpbro avatar jpbro commented on June 9, 2024

See changes to modTests.TestRegex2 method for a demonstration as per commit 66c88a1

from vbpcre2.

dragokas avatar dragokas commented on June 9, 2024

I see.
1

Strange, that PCRE2 produces in fact only one significant result: File1.zip.exe instead of three.

However, I think such .*$ regexp is incorrect at all. It is the same like (about)? regexp. Mean: you are trying to find empty string (as one of true results). If you enter such regexp e.g. on some online java regexp tester it will produce error, mean that regexp should not allow an empty strings as one of the true results of execution.

From this point of view, difference in results between VBS/PCRE2 is only a matter of its internal error handler mechanism which has different realization.

So, in real .+$ shoud be used instead of .*$.

As a conclusion, personally I believe that it is not necessary to touch such behavior. Anyway, if I would change something, I would detect regexp string that allow empty result and replace result string with raising error.

from vbpcre2.

dragokas avatar dragokas commented on June 9, 2024

Although, if VBS already produces the most complete result, I still would not have refused if PCRE2 would produces the same result to support strategy of PCRE2 as analogue of VBS.Regexp to show at least these 3 lines for .*$

  • File1.zip.exe
  • File2.com
  • File 3

But I don't khow, how you can track such cases and not break anything else.

from vbpcre2.

jpbro avatar jpbro commented on June 9, 2024

Yeah it's a bit of a weird one - interesting that some online regexp sites produce an error, but PCRE2 and VBScript produce results (albeit different). Makes it hard to know what the best approach is.

It might be that there is a PCRE2 option flag to handle this situation, I'll ahve to look at them all more closely (or maybe it's just up to my Global matching loop to work a bit differently to produce the same results as VBScript).

I don't have time to look closer right now, but I will try soon.

from vbpcre2.

dragokas avatar dragokas commented on June 9, 2024

According to my tests, no option pre-defined in your class allow to change behavior, except:

  • Dollar Matches End of string Only
  • Dot matches All Characters
    which affect all text falls into first substring, like:
    Match Count: 2
    
    #1: File1.zip.exe
    File2.com
    File 3
                                  Sub.#1: 
    #2: 
                                  Sub.#2: 

from vbpcre2.

skacurt avatar skacurt commented on June 9, 2024

Who is right?

Both results are correct. The wrong here is your expectation.

Multiline = True in VBScript's RegExp simply means ^$ match at line breaks which is an option that must explicitly set (as you did in VBScript) for PCRE, namely PCRE2_MULTILINE.

So it seems OK, you just changed the default behavior for VBScript but not for PCRE in your test.

from vbpcre2.

skacurt avatar skacurt commented on June 9, 2024

Oh, I forgot to mention. I've never used your wrapper.
If you're sure that the PCRE2_MULTILINE flag is set in your wrapper that means a problem of your wrapper or PCRE. VBScript's RegExp works as it should in this case.

from vbpcre2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.