mirror of https://github.com/Icinga/icinga2.git
parent
47b3ed948d
commit
059cda9e37
|
@ -399,6 +399,20 @@ Example:
|
||||||
|
|
||||||
"Hello World".find("World") /* Returns 6 */
|
"Hello World".find("World") /* Returns 6 */
|
||||||
|
|
||||||
|
### <a id="string-contains"></a> String#contains
|
||||||
|
|
||||||
|
Signature:
|
||||||
|
|
||||||
|
function contains(str);
|
||||||
|
|
||||||
|
Returns `true` if the string `str` was found in the string. If the string
|
||||||
|
was not found `false` is returned. Use [find](20-library-reference.md#string-find)
|
||||||
|
for getting the index instead.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
"Hello World".contains("World") /* Returns true */
|
||||||
|
|
||||||
### <a id="string-len"></a> String#len
|
### <a id="string-len"></a> String#len
|
||||||
|
|
||||||
Signature
|
Signature
|
||||||
|
|
|
@ -110,6 +110,13 @@ static Value StringFind(const std::vector<Value>& args)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool StringContains(const Value& value)
|
||||||
|
{
|
||||||
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
|
String self = vframe->Self;
|
||||||
|
return self.Contains(value);
|
||||||
|
}
|
||||||
|
|
||||||
static Value StringReplace(const String& search, const String& replacement)
|
static Value StringReplace(const String& search, const String& replacement)
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
|
@ -133,6 +140,7 @@ Object::Ptr String::GetPrototype(void)
|
||||||
prototype->Set("lower", new Function(WrapFunction(StringLower)));
|
prototype->Set("lower", new Function(WrapFunction(StringLower)));
|
||||||
prototype->Set("split", new Function(WrapFunction(StringSplit)));
|
prototype->Set("split", new Function(WrapFunction(StringSplit)));
|
||||||
prototype->Set("find", new Function(WrapFunction(StringFind)));
|
prototype->Set("find", new Function(WrapFunction(StringFind)));
|
||||||
|
prototype->Set("contains", new Function(WrapFunction(StringContains)));
|
||||||
prototype->Set("replace", new Function(WrapFunction(StringReplace)));
|
prototype->Set("replace", new Function(WrapFunction(StringReplace)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue