String Flashcards
What is the use of ascii_only method?
Returns true for a string which has only ASCII characters.
Is there any method called “b” in string?
yes.Returns a copied string whose encoding is ASCII-8BIT.
Which methods returns an array of the Integer ordinals of the characters in string?
codepoints
Where we can use “ord” method
to print integer ordinals of the string
differentiate - “hex’ and “oct” methods
hex - Treats leading characters from str as a string of hexadecimal digits
oct-Treats leading characters of str as a string of octal digits
Which method searches pattern (regexp) in the string and returns the part before it, the match, and the part after it.?
Partition method
How to remove invalid byte sequence in a string?
scrub method
“abc\u3042\x81”.scrub(“”) #=> “abc\u3042”
a = “ 3”
How you will get this string?(no concatenation)
“Ruby 3”
a.prepend(“Ruby”)
Which methods returns a new string where runs of the same character that occur in this set are replaced by a single character?
squeeze
What is the use of “to_c” method in String?
Returns a complex which denotes the string form.