Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby is character

#Use a regular expression that matches letters & digits:
def letter?(lookAhead)
  lookAhead.match?(/[[:alpha:]]/)
end

def numeric?(lookAhead)
  lookAhead.match?(/[[:digit:]]/)
end

#These are called POSIX bracket expressions, and the advantage of them is
#that unicode characters under the given category will match. For example:

'ñ'.match?(/[A-Za-z]/)     #=> false
'ñ'.match?(/w/)           #=> false
'ñ'.match?(/[[:alpha:]]/)  #=> true

#You can read more in Ruby’s docs for regular expressions.
#https://ruby-doc.org/core/Regexp.html
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #character
ADD COMMENT
Topic
Name
4+9 =