質問編集履歴

1

追記

2016/11/10 09:30

投稿

gogoackman3
gogoackman3

スコア109

test CHANGED
File without changes
test CHANGED
@@ -37,3 +37,47 @@
37
37
 
38
38
 
39
39
  なので、①の部分を【半角or全角スペース】がある、または【テキストの頭】という条件にしたいのですが、その場合、前述の正規表現をどう変更すれば良いのでしょうか??
40
+
41
+
42
+
43
+ 【追記】
44
+
45
+ 発生したエラー
46
+
47
+ ```ここに言語を入力
48
+
49
+ Processing by CommentsController#create as JS
50
+
51
+ Parameters: {"utf8"=>"✓", "authenticity_token"=>"f7WmhzeqykQ5m4PP0i+3FfiU6NMOVzPX98rL+hclJIqtp+Rc9em7OywPX9QWcQiARnMH2uWb4mLQHxU865EFcQ==", "comment"=>{"text"=>"#hash #hash1 #hash2 ", "user_id"=>"30"}, "commit"=>"投稿", "post_id"=>"62"}
52
+
53
+ User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 30 ORDER BY `users`.`id` ASC LIMIT 1
54
+
55
+ Post Load (0.3ms) SELECT `posts`.* FROM `posts` WHERE `posts`.`id` = 62 LIMIT 1
56
+
57
+ Game Load (0.3ms) SELECT `games`.* FROM `games` WHERE `games`.`id` = 5 LIMIT 1
58
+
59
+ Completed 500 Internal Server Error in 58ms (ActiveRecord: 0.9ms)
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+ NoMethodError (undefined method `gsub' for [""]:Array):
68
+
69
+ ```
70
+
71
+
72
+
73
+ メソッド
74
+
75
+ ```ここに言語を入力
76
+
77
+ def extraction_hashtag(string)
78
+
79
+ string.scan(/(^|[ ])[##][^ ]+/).map{ |a| a.gsub(/[ ]/, "")}
80
+
81
+ end
82
+
83
+ ```