- HOME>
- 正規表現>
- 正規表現 サンプル集
正規表現 | 指定した桁数を持つ数値かどうか
![正規表現 | 指定した桁数を持つ数値かどうか](https://1-notes.com/wp-content/uploads/2023/05/regex.png)
対象の値が指定した桁数を持つ数値かどうかを判定する正規表現パターンを紹介しています。
指定した桁数を持つ数値かどうかを判定する正規表現
対象の値が指定した桁数を持つ数値かかどうかを判別する正規表現パターンです。
下記の例では4桁の数値かどうかを判定するのに使う事ができる正規表現です。
^\d{4}$
上記、正規表現の判定結果は以下のようになります。
対象の文字列 | 判定 |
---|---|
1234 | true |
123 | false |
12345 | false |
Hello | false |
Posted by Yousuke.U
関連記事
![Thumbnail of related posts 029](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 029](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | クォーテーションをエスケープする
正規表現でのシングルクォーテーション、ダブルクオーテーションをエスケープする記述 ...
![Thumbnail of related posts 048](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 048](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 連続した改行コードがあるか、またはマッチする
対象の文字列に連続した改行コードがあるか、またはマッチする正規表現パターンを紹介 ...
![Thumbnail of related posts 106](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 106](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 郵便番号かどうか
対象の文字列が日本の郵便番号となっているかどうかを判別する正規表現パターンを紹介 ...
![Thumbnail of related posts 019](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 019](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 全角スペースが含まれているか、またはマッチする
対象の文字列から、全角スペースが含まれているか、またはマッチする正規表現パターン ...
![Thumbnail of related posts 099](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 099](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 英字・数字、英数字のみかどうか
対象の文字列が英字・数字、英数字のみかどうかを判別する正規表現パターンを紹介して ...
![Thumbnail of related posts 006](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 006](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | ひらがな、カタカナのみかどうか
対象の文字列がひらがな、カタカナ(半角、全角)のみかどうかを判別する正規表現パタ ...
![Thumbnail of related posts 188](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 188](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 末尾(最後の文字)のカンマにマッチする
対象の文字列にある末尾のカンマにマッチする正規表現パターンを紹介しています。 末 ...
![Thumbnail of related posts 139](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 139](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 言語別テスト用サンプルコード集
言語別に簡単な正規表現のテスト用サンプルコードを紹介しています。 PHP PHP ...
![Thumbnail of related posts 181](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 181](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 前方一致、後方一致しているかどうか
対象の文字列が指定した文字列で前方一致または後方一致しているかどうかを判別・取得 ...
![Thumbnail of related posts 098](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 098](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | メールアドレスかどうか
対象の文字列がメールアドレスとなっているかどうかを判別する正規表現パターンを紹介 ...
![Thumbnail of related posts 114](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 114](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | yyyy-mm-dd形式かどうか
対象の文字列がyyyy-mm-dd形式になっているかを判別する正規表現パターンを ...
![Thumbnail of related posts 000](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 000](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 括弧の中身にマッチする
対象の文字列にある括弧の中身にマッチする正規表現パターンを紹介しています。 括弧 ...
![Thumbnail of related posts 116](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 116](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | ファイルの拡張子が画像ファイルかどうか
対象のファイル名から拡張子が画像ファイルかどうかを判別する正規表現パターンを紹介 ...
![Thumbnail of related posts 004](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 004](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | HTMLタグかどうか、または含まれているか
対象の文字列がHTMLタグかどうか、または含まれているかかどうかを判別する正規表 ...
![Thumbnail of related posts 082](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
![Thumbnail of related posts 082](https://1-notes.com/wp-content/uploads/2023/05/regex-100x100.png)
正規表現 | 連続した半角スペース、全角スペースにマッチする
対象の文字列にある、2つ以上の連続した半角スペースにマッチする正規表現パターンを ...
ディスカッション
コメント一覧
まだ、コメントがありません