UIZE JavaScript Framework

MODULES Uize.Str.Has

1. Introduction

The Uize.Str.Has module provides methods for testing if a string starts with, ends with, or contains a specified substring.

DEVELOPERS: Chris van Rensburg

1.1. Examples

There are no dedicated showcase example pages for the Uize.Str.Has module.

SEARCH FOR EXAMPLES

Use the link below to search for example pages on the UIZE Web site that reference the Uize.Str.Has module...

SEARCH

1.2. Implementation Info

The Uize.Str.Has module defines the Uize.Str.Has package under the Uize.Str namespace.

1.2.1. Features Introduced in This Module

The features listed in this section have been introduced in this module.

STATIC METHODS

Uize.Str.Has.has | Uize.Str.Has.hasPrefix | Uize.Str.Has.hasSuffix

STATIC PROPERTIES

Uize.Str.Has.moduleName | Uize.Str.Has.pathToResources

1.2.2. Features Overridden in This Module

No features have been overridden in this module.

1.2.3. Features Inherited From Other Modules

This module has no inherited features.

1.2.4. Modules Directly Under This Namespace

There are no modules directly under this namespace.

1.2.5. Unit Tests

The Uize.Str.Has module is unit tested by the Uize.Test.Uize.Str.Has test module.

2. Static Methods

2.1. Uize.Str.Has.has

Returns a boolean, indicating whether or not the specified source string has the specified substring.

SYNTAX

hasBOOL = Uize.Str.Has.has (sourceSTR,subSTR);

If a source string starts with or ends with a substring, then that source string also has the substring. In other words, if Uize.Str.Has.hasPrefix (sourceStr,subStr) returns true, or if Uize.Str.Has.hasSuffix (sourceStr,subStr) returns true, then Uize.Str.Has.has (sourceStr,subStr) must also return true.

EXAMPLES

Uize.Str.Has.has ('JavaScript','Java');                 // returns true
Uize.Str.Has.has ('JavaScript','JavaScript');           // returns true
Uize.Str.Has.has ('JavaScript','Script');               // returns true
Uize.Str.Has.has ('JavaScript','S');                    // returns true
Uize.Str.Has.has ('JavaScript','ava');                  // returns true
Uize.Str.Has.has ('JavaScript','');                     // returns true
Uize.Str.Has.has ('','');                               // returns true
Uize.Str.Has.has ('JavaScript','JAVASCRIPT');           // returns false
Uize.Str.Has.has ('JavaScript','script');               // returns false
Uize.Str.Has.has ('Java','JavaScript');                 // returns false
Uize.Str.Has.has ('JavaScript','Java Script');          // returns false
Uize.Str.Has.has ('JavaScript','JavaScript   ');        // returns false
Uize.Str.Has.has ('JavaScript','   JavaScript');        // returns false
Uize.Str.Has.has ('JavaScript','JavaScript Framework'); // returns false

NOTES

see the related Uize.Str.Has.hasPrefix and Uize.Str.Has.hasSuffix static methods
this method is case sensitive

IMPLEMENTATION INFO

this feature was introduced in this module

2.2. Uize.Str.Has.hasPrefix

Returns a boolean, indicating whether or not the specified source string starts with the specified prefix string.

SYNTAX

hasPrefixBOOL = Uize.Str.Has.hasPrefix (sourceSTR,subSTR);

The test that this method performs is case and space sensitive. In cases where you need to test without regards to case or whitespace, it is best to construct a regular expression using the "^" (anchor to beginning) metacharacter and the i (case-insensitivity) switch.

EXAMPLES

Uize.Str.Has.hasPrefix ('JavaScript','Java');                 // returns true
Uize.Str.Has.hasPrefix ('Java','JavaScript');                 // returns false
Uize.Str.Has.hasPrefix ('JavaScript','JavaScript');           // returns true
Uize.Str.Has.hasPrefix ('JavaScript','Java Script');          // returns false
Uize.Str.Has.hasPrefix ('JavaScript','JavaScript   ');        // returns false
Uize.Str.Has.hasPrefix ('JavaScript','   JavaScript');        // returns false
Uize.Str.Has.hasPrefix ('JavaScript','JAVASCRIPT');           // returns false
Uize.Str.Has.hasPrefix ('JavaScript','Script');               // returns false
Uize.Str.Has.hasPrefix ('JavaScript','JavaScript Framework'); // returns false
Uize.Str.Has.hasPrefix ('JavaScript','');                     // returns true

NOTES

see the companion Uize.Str.Has.hasSuffix static method
see the related Uize.Str.Has.has static method
when the value '' (empty string) is specified for the subSTR parameter, this method will return true (all strings can be said to start with an empty string)

IMPLEMENTATION INFO

this feature was introduced in this module

2.3. Uize.Str.Has.hasSuffix

Returns a boolean, indicating whether or not the specified source string ends with the specified suffix string.

SYNTAX

hasSuffixBOOL = Uize.Str.Has.hasSuffix (sourceSTR,subSTR);

The test that this method performs is case and space sensitive. In cases where you need to test without regards to case or whitespace, it is best to construct a regular expression using the "$" (anchor to end) metacharacter and the i (case-insensitivity) switch.

EXAMPLES

Uize.Str.Has.hasSuffix ('JavaScript','Java');                 // returns false
Uize.Str.Has.hasSuffix ('Java','JavaScript');                 // returns false
Uize.Str.Has.hasSuffix ('JavaScript','JavaScript');           // returns true
Uize.Str.Has.hasSuffix ('JavaScript','Java Script');          // returns false
Uize.Str.Has.hasSuffix ('JavaScript','JavaScript   ');        // returns false
Uize.Str.Has.hasSuffix ('JavaScript','   JavaScript');        // returns false
Uize.Str.Has.hasSuffix ('JavaScript','JAVASCRIPT');           // returns false
Uize.Str.Has.hasSuffix ('JavaScript','Script');               // returns true
Uize.Str.Has.hasSuffix ('JavaScript','JavaScript Framework'); // returns false
Uize.Str.Has.hasSuffix ('JavaScript','');                     // returns true

NOTES

see the companion Uize.Str.Has.hasPrefix static method
see the related Uize.Str.Has.has static method
when the value '' (empty string) is specified for the subSTR parameter, this method will return true (all strings can be said to end with an empty string)

IMPLEMENTATION INFO

this feature was introduced in this module

3. Static Properties

3.1. Uize.Str.Has.moduleName

IMPLEMENTATION INFO

this feature was introduced in this module

3.2. Uize.Str.Has.pathToResources

IMPLEMENTATION INFO

this feature was introduced in this module