الفرق بين المراجعتين لصفحة: «وحدة:String»

اذهب إلى التنقل اذهب إلى البحث
أُضيف ٩٦٦ بايت ،  قبل ٣ سنوات
separate annotations for str.match from those for str._match
كوبتيكبيديا>Mohammed-Qubati
كوبتيكبيديا>Mohammed-Qubati (ترجمة)
 
كوبتيكبيديا>RexxS
كوبتيكبيديا>RexxS (separate annotations for str.match from those for str._match)
سطر ١: سطر ١:
--[[
--[[


الغرض من هذه الوحدة هو توفير الوصول إلى .وظائف السلسلة الأساسية
This module is intended to provide access to basic string functions.


يمكن استدعاء معظم الوظائف المقدمة هنا باستخدام معلمات مسماة أو معلمات غير مسماة أو خليط.  إذا تم استخدام المعلمات المسماة، سيقوم ويكيميديا تلقائيًا بإزالة أي مسافة بيضاء بادئة أو لاحقة من المعلمةاعتمادًا على الاستخدام المقصود ، قد يكون من المفيد إما الحفاظ على مثل هذه المساحة البيضاء أو إزالتها..
Most of the functions provided here can be invoked with named parameters,
unnamed parameters, or a mixtureIf named parameters are used, Mediawiki will
automatically remove any leading or trailing whitespace from the parameter.
Depending on the intended use, it may be advantageous to either preserve or
remove such whitespace.


Global options
Global options
     ignore_errors: إذا تم تعيينه 'true' أو 1, أي خطأ سيؤدي إلى
     ignore_errors: If set to 'true' or 1, any error condition will result in
         إرجاع سلسلة فارغة بدلاً من رسالة خطأ.
         an empty string being returned rather than an error message.


     error_category: في حالة حدوث خطأ، يتم تحديد اسم الفئة بـ
     error_category: If an error occurs, specifies the name of a category to
         لتضمينه مع رسالة الخطأالفئة الافتراضية هي
        include with the error messageThe default category is
         [Category:Errors reported by Module String].
         [Category:Errors reported by Module String].


     no_category: إذا تم تعيينه 'true' أو 1، لن يتم إضافة أي فئة إذا حدث خطأ
     no_category: If set to 'true' or 1, no category will be added if an error
         تم إنشاؤه.
        is generated.


Unit tests for this module are available at Module:String/tests.
Unit tests for this module are available at Module:String/tests.
سطر ٢٤: سطر ٢٨:
len
len


تُرجع هذه الدالة طول السلسلة المستهدفة.
This function returns the length of the target string.


Usage:
Usage:
سطر ١٠٣: سطر ١٠٧:


--[[
--[[
match
_match


This function returns a substring from the source string that matches a
This function returns a substring from the source string that matches a
specified pattern.
specified pattern. It is exported for use in other modules


Usage:
Usage:
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}
strmatch = require("Module:String")._match
OR
sresult = strmatch( s, pattern, start, match, plain, nomatch )
{{#invoke:String|pos|s=source_string|pattern=pattern_string|start=start_index
    |match=match_number|plain=plain_flag|nomatch=nomatch_output}}


Parameters
Parameters
سطر ١٢٧: سطر ١٢٩:
         text.  Defaults to false.
         text.  Defaults to false.
     nomatch: If no match is found, output the "nomatch" value rather than an error.
     nomatch: If no match is found, output the "nomatch" value rather than an error.
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from each string.  In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
If the match_number or start_index are out of range for the string being queried, then
this function generates an error.  An error is also generated if no match is found.
If one adds the parameter ignore_errors=true, then the error will be suppressed and
an empty string will be returned on any failure.


For information on constructing Lua patterns, a form of [regular expression], see:
For information on constructing Lua patterns, a form of [regular expression], see:
سطر ٢٠٥: سطر ١٩٨:
end
end
end
end
--[[
match
This function returns a substring from the source string that matches a
specified pattern.
Usage:
{{#invoke:String|match|source_string|pattern_string|start_index|match_number|plain_flag|nomatch_output}}
OR
{{#invoke:String|match|s=source_string|pattern=pattern_string|start=start_index
    |match=match_number|plain=plain_flag|nomatch=nomatch_output}}
Parameters
    s: The string to search
    pattern: The pattern or string to find within the string
    start: The index within the source string to start the search.  The first
        character of the string has index 1.  Defaults to 1.
    match: In some cases it may be possible to make multiple matches on a single
        string.  This specifies which match to return, where the first match is
        match= 1.  If a negative number is specified then a match is returned
        counting from the last match.  Hence match = -1 is the same as requesting
        the last match.  Defaults to 1.
    plain: A flag indicating that the pattern should be understood as plain
        text.  Defaults to false.
    nomatch: If no match is found, output the "nomatch" value rather than an error.
If invoked using named parameters, Mediawiki will automatically remove any leading or
trailing whitespace from each string.  In some circumstances this is desirable, in
other cases one may want to preserve the whitespace.
If the match_number or start_index are out of range for the string being queried, then
this function generates an error.  An error is also generated if no match is found.
If one adds the parameter ignore_errors=true, then the error will be suppressed and
an empty string will be returned on any failure.
For information on constructing Lua patterns, a form of [regular expression], see:
* http://www.lua.org/manual/5.1/manual.html#5.4.1
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns
]]
-- This is the entry point for #invoke:String|match
-- This is the entry point for #invoke:String|match
function str.match( frame )
function str.match( frame )
مستخدم مجهول

قائمة التصفح