Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find_all to eregmatch() nasl function #875

Merged
merged 3 commits into from Sep 15, 2021

Conversation

jjnicola
Copy link
Member

@jjnicola jjnicola commented Sep 14, 2021

What:
Add find_all to eregmatch() nasl function

Jira: SC-395

Why:
The current implementation only returns the first match in the string.
Now it will return all matches if the option find_all: TRUE is passed to the function.
For backward compatibility, if FALSE is passed or no option, it will return the first match as before.

How:
Run the following nasl script with openvas-nasl without the option, with the option set FALSE/TRUE

foo = "11 abc
22 def
221 def
222 def
223 def
224 def
225 def
3333 ghi";
bar = eregmatch(string:foo, pattern:"[0-9]+", find_all: TRUE);
#display(foo);
display(bar);

Checklist:

The current implementation only returns the first match in the string.
Now it will return all matches if the option `find_all: TRUE` is passed to the function.
For backward compatibility, if FALSE is passed or no option, it will return the first match as before.
@y0urself y0urself merged commit af3c436 into greenbone:openvas-21.04 Sep 15, 2021
y0urself added a commit that referenced this pull request Sep 15, 2021
[middleware] Add `find_all` to eregmatch() nasl function. Backport #875
y0urself added a commit that referenced this pull request Sep 15, 2021
[master] Add `find_all` to eregmatch() nasl function. Backport #875
@jjnicola jjnicola deleted the regex branch February 24, 2022 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants