从给定文件中我只想检索具有'rt_view_product'的行然后'user_id'
我的代码是:
public function send(ContactFormRequest $request)
{
$data = $request->all();
Mail::send('emails.contact', $data, function ($message) use ($data) {
$message->from('contact@example.com', 'Contact Form');
$message->to('me@mail.com')->subject('test');
if($data['document'] != '')
{
$message->attachData($data['document'], $data['document']->getClientOriginalName());
}
});
return "Your email has been sent successfully";
}
我知道'some_file'有这种行,但view_event.log仍为空
我也在https://regex101.com/检查我的正则表达式,它似乎工作正常
这里是'some_file'行的一个例子:
cat some_file | grep '"(rt_view_product)(.*)(user_id)*"' >> view_event.log
并且我想保存:
/v1/events?os=android&bundle=test&event=rt_view_product&network=Organic&ip=0.0.0.0&time=1437352628&country=th&device_name=TRUESMART4.0&os_version=19&session=12&adid=d963faa323b2cd971467d7ddd63b5125&google_play_advertising_id=d9676bba-b664-4d0b-be3d-94e542e0768c&language=th&tracking_enabled=1&time_spent=1618&environment=production&timezone=UTC%2B0700&sdk_version=android4.0.5&device=Phone&device_model=TRUE+SMART+4.0&display_size=3.88&app_version=3.0.12&device_manufacturer=alps&gender=Male&product=ODFLKGJDFLKGJ&shop_country=TH&user_id=7474774
答案 0 :(得分:0)
您不需要使用括号:
$ echo "rt_view_product something user_id" > foo
$ grep 'rt_view_product.*user_id' foo
rt_view_product something user_id