Last modified: 2012-08-29 16:09:52 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T41766, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 39766 - string.find only return only a number instead of an array
string.find only return only a number instead of an array
Status: RESOLVED WORKSFORME
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-29 15:35 UTC by Tpt
Modified: 2012-08-29 16:09 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Tpt 2012-08-29 15:35:44 UTC
string.find function only return a number instead of an array.

Some examples:
string.find("d'alfdf", "(al)") return 3 instead of {3, 4, "al"}
= string.find("d'alfdf", "^([a-d'])") return 1 instead of {1, 1, d}

Lua manual say :
string.find (s, pattern [, init [, plain]])
Looks for the first match of pattern in the string s. If it finds a match, then find returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. [...]

If the pattern has captures, then in a successful match the captured values are also returned, after the two indices.
Comment 1 Victor Vasiliev 2012-08-29 15:46:03 UTC
The following code:

a, b, c = string.find("d'alfdf", "(al)")
print(b)

outputs 4 on mediawiki.org (at least in debug console).
Comment 2 Tpt 2012-08-29 16:09:52 UTC
Thanks a lot ! It's works find. Sorry for having wasted your time.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links