Skip to content

Commit

Permalink
- Added several String testing methods, such as is_lowercase, `is_u…
Browse files Browse the repository at this point in the history
…ppercase`, `is_space`, `is_ascii`, etc...
  • Loading branch information
trizen committed Jul 27, 2019
1 parent 23b911f commit 814089e
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
71 changes: 71 additions & 0 deletions lib/Sidef/Types/String/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,77 @@ package Sidef::Types::String::String {
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_lowercase {
my ($self) = @_;
($$self =~ /^[[:lower:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

*is_lc = \&is_lowercase;

sub is_uppercase {
my ($self) = @_;
($$self =~ /^[[:upper:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

*is_uc = \&is_uppercase;

sub is_ascii {
my ($self) = @_;
($$self =~ /^[[:ascii:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_space {
my ($self) = @_;
($$self =~ /^[[:space:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_word {
my ($self) = @_;
($$self =~ /^[[:word:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_punctuation {
my ($self) = @_;
($$self =~ /^[[:punct:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

*is_punct = \&is_punctuation;

sub is_digit {
my ($self) = @_;
($$self =~ /^[[:digit:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_alpha {
my ($self) = @_;
($$self =~ /^[[:alpha:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

sub is_alphanum {
my ($self) = @_;
($$self =~ /^[[:alnum:]]+\z/)
? (Sidef::Types::Bool::Bool::TRUE)
: (Sidef::Types::Bool::Bool::FALSE);
}

*is_alnum = \&is_alphanum;

sub index {
my ($self, $substr, $pos) = @_;
Sidef::Types::Number::Number->_set_int(
Expand Down
80 changes: 80 additions & 0 deletions lib/Sidef/Types/String/String.pod
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,40 @@ Aliases: I<integers>

=cut

=head2 is_alnum

String.is_alnum() -> I<Obj>

Return the

Aliases: I<is_alphanum>

=cut

=head2 is_alpha

String.is_alpha() -> I<Obj>

Return the

=cut

=head2 is_ascii

String.is_ascii() -> I<Obj>

Return the

=cut

=head2 is_digit

String.is_digit() -> I<Obj>

Return the

=cut

=head2 is_empty

String.is_empty() -> I<Obj>
Expand All @@ -636,6 +670,16 @@ Return the

=cut

=head2 is_lc

String.is_lc() -> I<Obj>

Return the

Aliases: I<is_lowercase>

=cut

=head2 is_numeric

String.is_numeric() -> I<Obj>
Expand All @@ -654,6 +698,42 @@ Return the

=cut

=head2 is_punct

String.is_punct() -> I<Obj>

Return the

Aliases: I<is_punctuation>

=cut

=head2 is_space

String.is_space() -> I<Obj>

Return the

=cut

=head2 is_uc

String.is_uc() -> I<Obj>

Return the

Aliases: I<is_uppercase>

=cut

=head2 is_word

String.is_word() -> I<Obj>

Return the

=cut

=head2 iter

String.iter() -> I<Obj>
Expand Down

0 comments on commit 814089e

Please sign in to comment.