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?

ChatGPT先生へ「正規表現を教えて下さい。」文字A_数字_文字B → 字C_数字_文字D

Last updated at Posted at 2025-12-01

(本日の)ChatGPT先生へ

以下の、正規表現を教えて下さい。
*区分所有法27条
      ↓
*https://ja.wikibooks.org/wiki/建物の区分所有等に関する法律第27条

*区分所有法48条の2
      ↓
*https://ja.wikibooks.org/wiki/建物の区分所有等に関する法律第48条の2

回答抜粋

正規表現(変換パターン)

・例(Python)

import re

pattern = re.compile(r'^(*\s*)(区分所有法)\s*(\d+)(条(?:の\d+)?)\s*$')
for s in ['*区分所有法27条', '*区分所有法48条の2']:
    print(re.sub(pattern, r'\1https://ja.wikibooks.org/wiki/建物の区分所有等に関する法律第\3\4', s))

・出力:

*https://ja.wikibooks.org/wiki/建物の区分所有等に関する法律第27条
*https://ja.wikibooks.org/wiki/建物の区分所有等に関する法律第48条の2
0
0
0

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?