0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python to RubyAdvent Calendar 2021

Day 19

[py2rb] isupper isalpha

Last updated at Posted at 2021-12-22

はじめに

移植やってます

isupper isalpha (Python)

if sequence.isupper() and sequence.isalpha():

この場合、文字列sequenceが英字で大文字ですね。

[追記]
コメント欄に、興味深い話があります。

Regexp (Ruby)

sequence = 'ABCDEF'
puts sequence =~ /^[A-Z]+$/
sequence = 'abcdef'
puts sequence =~ /^[A-Z]+$/
sequence = 'ABC123'
puts sequence =~ /^[A-Z]+$/
sequence = 'ABCdef'
puts sequence =~ /^[A-Z]+$/
sequence = 'ABCD-F'
puts sequence =~ /^[A-Z]+$/

正規表現ですよね。
\A...\zって書いたほうが良いそうです。

メモ

  • Python の isupper isalpha を学習した
  • 道のりは遠そう
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?