mori– Author –
-
C#樹林
[C#] Extracting a Single Match from a String Using Regex Pattern (Regex.Match)
To find a specific pattern (such as an order number, ID, or amount) within a string and retrieve only the first occurrence, use the Regex.Match method. Also, by using the "Grouping ()" feature of regular expressions, you can extract just... -
C#樹林
【C#】文字列の中から正規表現パターンに一致する箇所をひとつだけ取り出す (Regex.Match)
文字列の中から、特定のパターン(注文番号、ID、金額など)に合致する部分を探し出し、最初に見つかった1つだけを取得するには Regex.Match メソッドを使用します。 また、正規表現の「グループ化 ()」という機能を使うと、「注文ID全体」ではなく「IDの... -
C#樹林
[C#] Checking if a String Matches a Regular Expression Pattern (Regex.IsMatch)
When checking if data entered by a user is in the correct format (e.g., zip codes, phone numbers, or email addresses), Regular Expressions are a very powerful tool. In C#, you can use the Regex.IsMatch method from the System.Text.Regular... -
C#樹林
【C#】文字列が正規表現パターンに一致するか判定する (Regex.IsMatch)
ユーザーが入力したデータが正しい形式になっているか(例:郵便番号、電話番号、メールアドレスなど)をチェックする際、正規表現(Regular Expressions) は非常に強力なツールです。 C#では System.Text.RegularExpressions 名前空間の Regex.IsMatch ... -
C#樹林
[C#] Defining Custom Attributes and Controlling Behavior with Reflection
In C#, in addition to standard attributes (like [Obsolete] or [Serializable]), developers can define their own attributes (custom attributes). By using this, you can attach unique metadata (marks such as "this item is required" or "autom... -
C#樹林
【C#】独自の属性(Attribute)を定義してリフレクションで動作を制御する方法
C#では、標準で用意されている属性([Obsolete] や [Serializable] など)以外に、開発者が独自の属性(カスタム属性)を定義することができます。 これを利用すると、クラスやプロパティに対して独自のメタデータ(「この項目は必須」「この項目は自動変... -
Python樹林
[Python] Handling ZIP Files: How to Extract and Manipulate Using the zipfile Module
Python's standard library zipfile module allows you to extract (unzip) ZIP archives or check the list of filenames inside without extracting. This article explains operations ranging from basic handling to processing password-protected Z... -
Python樹林
【Python】ZIPファイルの展開と操作:zipfileモジュールの使い方
Python標準ライブラリの zipfile モジュールを使用すると、ZIP形式の圧縮ファイルを解凍(展開)したり、解凍せずに中身のファイル名一覧を確認したりできます。 ここでは、業務データのバックアップファイル(ZIP)を操作するシナリオを例に、基本操作か... -
Python樹林
[Python] Generating Hash Values: Usage of hashlib (SHA256, MD5, etc.)
Python's standard library hashlib module allows you to easily generate hash values (message digests) from strings or files. Hash values are widely used for security and data integrity checks, such as password storage and file tampering d... -
Python樹林
【Python】ハッシュ値を生成する:hashlibの使い方(SHA256, MD5等)
Pythonの標準ライブラリ hashlib モジュールを使用すると、文字列やファイルから**ハッシュ値(メッセージダイジェスト)**を簡単に生成できます。 ハッシュ値は、パスワードの保存やファイルの改ざん検知など、セキュリティやデータ整合性の確認に広く利... -
Python樹林
[Python] Restoring Unicode Escape Strings: Using the codecs Module
In API responses or server logs, text is sometimes recorded in the \uXXXX format (Unicode Escape). This article explains how to decode such data back into its original string format using Python's codecs module. We will implement a syste... -
Python樹林
【Python】ユニコードエスケープ文字列を復元する:codecsモジュールの活用
APIのレスポンスやサーバーの生ログなど、日本語が \uXXXX 形式(ユニコードエスケープ)で記録されているデータを、Pythonの codecs モジュールを使用して本来の文字列に復元(デコード)する方法を解説します。 ここでは、サーバーから受信した「ステー... -
Python樹林
[Python] How to Convert Strings to Unicode Escape Format
There are cases where you need to convert multi-byte characters (such as Japanese or emojis) into an ASCII-only string composed of "Unicode escape sequences" in the format \uXXXX. This is often used for data transmission to legacy system... -
Python樹林
【Python】文字列をユニコードエスケープ形式に変換する方法
日本語などのマルチバイト文字を、\uXXXX という形式の「ユニコードエスケープシーケンス」のみで構成されたASCII文字列に変換したい場合があります。 これは、ASCII文字しか扱えない古いシステムへのデータ送信や、設定ファイルでの文字化け防止などに利... -
Python樹林
[Python] How to Parse URL Query Parameters into a Dictionary
In web application development or scraping, you often need to analyze query parameters at the end of a URL (in the format ?key=value&...) and handle them as a Python dictionary. You can easily perform this conversion using the parse_... -
Python樹林
【Python】URLのクエリパラメータをパースして辞書(dict)に変換する方法
Webアプリケーション開発やスクレイピングにおいて、URLの末尾にある ?key=value&... という形式のクエリパラメータを解析し、Pythonの辞書として扱いたい場合があります。 標準ライブラリ urllib.parse モジュールの parse_qs() 関数を使用すると、こ... -
Python樹林
[Python] How to Parse URLs to Extract Components (Domain, Path, Query, etc.)
In web scraping or API integration processes, you often need to extract specific parts from a long URL string, such as just the "domain name" or only the "query parameters." By using the urlparse() function from Python's standard library... -
Python樹林
【Python】URLをパースして構成要素(ドメイン・パス・クエリ等)を取得する方法
WebスクレイピングやAPI連携の処理において、1つの長いURL文字列から「ドメイン名だけ」や「クエリパラメータだけ」を抜き出したい場合があります。 Pythonの標準ライブラリ urllib.parse モジュールにある urlparse() 関数を使用すると、URLを6つの構成要... -
Python樹林
[Python] How to URL Encode and Decode Strings (Handling Non-ASCII Characters)
As a general rule, URLs in web browsers can only contain alphanumeric characters and certain symbols (ASCII characters). Therefore, if you want to include spaces, special symbols, or non-ASCII characters in a URL, you must convert them i... -
Python樹林
【Python】URLエンコードとデコードの方法:日本語を含むURLの処理
Webブラウザのアドレスバーに入力するURLには、原則として半角英数字と一部の記号(ASCII文字)しか使用できません。 そのため、日本語のキーワードやスペース、特殊記号などをURLに含める場合は、「パーセントエンコーディング(URLエンコード)」と呼ば... -
C#樹林
[C#] Batch Convert All Null String Properties to Empty Strings
When saving data to a database or returning data as an API response, you may want to unify all null string properties to empty strings (""). If there are only a few properties, you can manually write if (str == null) str = "";. However, ... -
C#樹林
【C#】オブジェクト内のnullの文字列プロパティをすべて空文字(“”)に一括変換する
データベースへの保存前や、APIレスポンスとしてデータを返す際、文字列プロパティに含まれる null をすべて空文字列("")に統一したい場合があります。 プロパティが数個であれば手動で if (str == null) str = ""; と書けますが、プロパティ数が多い場... -
C#樹林
[C#] Batch Convert All Object Property Names and Values to a Dictionary
When creating request parameters for an API or outputting logs, you may often want to convert a class or anonymous type object into "property name" and "value" pairs (key-value format). By using Reflection, you can create a generic conve... -
C#樹林
【C#】オブジェクトの全プロパティ名と値をDictionaryに一括変換する
APIへのリクエストパラメータ作成やログ出力などで、クラスや匿名型のオブジェクトを「プロパティ名」と「値」のペア(キーバリュー形式)に変換したい場合があります。 リフレクションを使用することで、型定義に依存しない汎用的な変換メソッドを作成で... -
Python樹林
[Python] UUID Generation and Types (v1, v4, v3, v5): Namespaces and Uniqueness
A UUID (Universally Unique Identifier) is an identifier used to generate globally unique IDs without central management. It is represented as a 128-bit number in hexadecimal format, looking like 550e8400-e29b-41d4-a716-446655440000. Usin... -
Python樹林
【Python】UUIDの生成と種類の使い分け(v1, v4, v3, v5):名前空間と一意性
UUID(Universally Unique Identifier)とは、中央管理なしに、世界中で重複しない(事実上一意な)IDを生成するための識別子です。 128ビットの数値を16進数で表現し、「550e8400-e29b-41d4-a716-446655440000」のような形式になります。 Pythonの標準ラ... -
Python樹林
[Python] How to Decode Base64 Strings and Restore Original Files
To restore "Base64 encoded strings" received from Web APIs or email attachments back to their original binary data (images, PDFs, audio files, etc.), use the b64decode() function from the standard base64 module. This article explains how... -
Python樹林
【Python】Base64文字列をデコードして元のファイル(画像など)に復元する方法
Web APIやメール添付などで受け取った「Base64エンコードされた文字列」を、元のバイナリデータ(画像、PDF、音声ファイルなど)に戻して保存するには、標準ライブラリ base64 モジュールの b64decode() 関数を使用します。 ここでは、受信したBase64文字... -
Python樹林
[Python] How to Encode Binary Data (Images, etc.) to Base64 Format
Base64 is an encoding method that converts binary data, such as image files or audio data, into text (strings) composed of only 64 types of alphanumeric characters. This allows binary data to be sent and received via text-based protocols... -
Python樹林
【Python】バイナリデータ(画像など)をBase64形式にエンコードする方法
Base64は、画像ファイルや音声データなどのバイナリデータを、64種類の英数字のみで構成されるテキスト(文字列)データに変換するエンコーディング方式です。 これにより、バイナリデータを扱えないテキストベースのプロトコル(JSONでのデータ送信や、HT...