locutusjs / locutus

Bringing stdlibs of other programming languages to JavaScript for educational purposes

Home Page:https://locutus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure to recognize some format and extract values in sscanf

mortezafs opened this issue · comments

Hi.
First of all thank you for your great job.
I'm going to report some bug in sscanf function.
sscanf can not recognize this formats and extract matched values.
Tested at: Windows and ubnutu

Format 1: "%[^[]]"
Test Case:

let dataScanned = sscanf('mobile[country_code]', '%[^[]]');
console.log(dataScanned);

JS sscanf output:
[]
PHP output:

Array
(
    [0] => mobile
)

Format 2: "%[^[][%[^]]]"
Test Case:

let dataScanned = sscanf("alphanumericWithCustomChars[en,fa|-|_|)|(]", "%[^[][%[^]]]");
console.log(dataScanned);

JS sscanf output:
[]
PHP output:

Array
(
    [0] => alphanumericWithCustomChars
    [1] => en,fa|-|_|)|(
)