Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
\1次の正規表現があります。値を別の変数に保存するにはどうすればよいですか?
\1
image_id = A8064ABAAAGAAT120108.1 version = re.sub(r'^.*?(\d+\D*)(\..*)', r'\1T\2', image_id)
文字列内の正規表現を一致させる方がよいでしょう。
pattern = re.compile('.*?(\d+\D*)(\..*)') k = pattern.search(image_id) saved_value = k.groups()[0] # this will give you the value # of the fist matched group # as a string