Code Monkey home page Code Monkey logo

Comments (6)

renshijun avatar renshijun commented on August 26, 2024

The following is ttt.cc:
------------------------------------------------------------------------------------file begin
local str = "- OAB/SP nº.:205844;";
local rex = regexp(@"(OAB)([^\d]{0,10})(\d[\d.]+)(.)");
local res = rex.capture(str);
foreach(i,val in res)
{
print(format("match number[%02d] %s\n", i,str.slice(val.begin,val.end)));
}
------------------------------------------------------------------------------------file end
execute ../bin/sq ttt.cc returns:
-----------------------------------------------------------------results begin
match number[00] OAB/SP nº.:205844;
match number[01] OAB
match number[02] /SP nº.:205844
match number[03] 205844
match number[04] ;
-----------------------------------------------------------------results end

from squilu.

mingodad avatar mingodad commented on August 26, 2024

I'm not sure I understand what you are trying to say.
Have you done any change to regex ?
Are you reporting a bug ?
Cheers !

from squilu.

renshijun avatar renshijun commented on August 26, 2024

you can download my modified sqstdrex.cpp file to see the difference with squirrel3.

from squilu.

mingodad avatar mingodad commented on August 26, 2024

Hello renshijun !
Thank you for your work !
Are you aware of this albertodemichelis/squirrel#181 and if so your work fix it ?
Cheers !

from squilu.

renshijun avatar renshijun commented on August 26, 2024

For a regrex object, the first capture returns right result but the second capture returns wrong result. It seem not very hard to solve the problem. you can see my post in albertodemichelis/squirrel#181.

from squilu.

renshijun avatar renshijun commented on August 26, 2024

I solve the problem albertodemichelis/squirrel#181.

In function SQBool sqstd_rex_search() reset match len to 0. add the following first.
for(int i=0;i_nsubexpr;i++)
exp->_matches[i].len = 0;

----------------------------------------------------------------------sss.cc begin
function formatCapture(cap) {
if (cap == null) return "no match";
// If there is a match, show the start and end index, and the length
else return format("[%d,%d] (%d)", cap[0].begin, cap[0].end, cap[0].end - cap[0].begin);
}
local re = regexp("a.*?bc");
local strs = [
"a bcd",
"a bc bcd",
"a b bcd",
];
foreach (fff in strs)
{
print(formatCapture(re.capture(fff)) + "\n");
}
print("-----------------\n")
re=regexp("a.*bc")
foreach (fff in strs)
{
print(formatCapture(re.capture(fff)) + "\n");
}
------------------------------------------------------------------------------------end

../bin/sq sss.cc returns:
bash-5.0# ../bin/sq sss.cc
[0,4] (4)
[0,4] (4)
[0,6] (6)

[0,4] (4)
[0,7] (7)
[0,6] (6)
bash-5.0#

from squilu.

Related Issues (3)

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.