質問するログイン新規登録

回答編集履歴

4

テキスト修正

2018/10/22 14:38

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
File without changes

3

テキスト修正

2018/10/22 14:38

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -48,4 +48,4 @@
48
48
 
49
49
  以下は、上記の正規表現にマッチする文字列を判定するコード例です。
50
50
 
51
- - [https://www.jdoodle.com/a/Kc4](https://www.jdoodle.com/a/Kc4)
51
+ - **動作確認用サンプル: ** [https://www.jdoodle.com/a/Kc4](https://www.jdoodle.com/a/Kc4)

2

テキスト修正

2018/10/22 14:37

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -33,4 +33,19 @@
33
33
 
34
34
  - **動作確認用サンプル: ** [https://www.jdoodle.com/a/Kb6](https://www.jdoodle.com/a/Kb6)
35
35
 
36
- 一番左の[Execute]ボタンをクリックすると実行されます。(jdoodleだと日本語の文字列は化けるようです。)
36
+ 一番左の[Execute]ボタンをクリックすると実行されます。(jdoodleだと日本語の文字列は化けるようです。)
37
+
38
+ #### 追記
39
+
40
+ 正規表現でやるとすれば、Oreilly [Regular Expressions Cookbook](http://shop.oreilly.com/product/0636920023630.do) の
41
+ - [6.7. Numbers Within a Certain Range](https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch06s07.html)
42
+
43
+ に載っている、以下を使うのがよいかと思います。
44
+
45
+ > –128 to 127 (signed byte):
46
+ >
47
+ > ^(12[0-7]|1[01][0-9]|[1-9]?[0-9]|-(12[0-8]|1[01][0-9]|[1-9]?[0-9]))$
48
+
49
+ 以下は、上記の正規表現にマッチする文字列を判定するコード例です。
50
+
51
+ - [https://www.jdoodle.com/a/Kc4](https://www.jdoodle.com/a/Kc4)

1

テキスト修正

2018/10/22 14:34

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -12,7 +12,7 @@
12
12
  public class Q153589 {
13
13
  public static void main(String args[]) {
14
14
 
15
- String[] data = { "101", "ajt", "あああ", "121", "-1", "256" };
15
+ String[] data = { "101", "ajt", "あああ", "121", "-1", "128" };
16
16
  List<Byte> byteValues = new ArrayList<>();
17
17
 
18
18
  for (String s: data) {