can someone help me with preg_match? - preg-match

i can't find solution how to read correctly the message, this is model of message:
209937
Maks ) Message
11:52
Tedy...Hi 12:01
Maks )Hello12:07
Tedy...How are you?
Update Messages
Delete all messages
MyPage Messages
I need to check if message is sent, the model of message is it: first line is sent time, next line is
nickname and message, also time of next message
[hh:mm1]
[Nickname1][Message1][hh:mm2]
[Nickname2][Message2][hh:mm3]
[Nickname1][Message3]
Thanks in advance for any tips.

<?php
$sample_text = <<<EOF
209937
Maks ) Message
11:52
Tedy...Hi
12:01
Maks )Hello )
12:07
Tedy...How are you?
Update Messages
Delete all messages
MyPage Messages
EOF;
preg_match_all('/(?\'time\'(\d{1,2}\:\d{2}))[^\w]*(?\'who\'(\w+))(?\'what\'([^\d]+))/', $sample_text, $messages);
echo '<pre>' . print_r($messages, true) . '</pre>';
?>

Related

Update record of Authentication system in laravel without Error message

I used Authentication system and want to update record of user is "logged in" and use this code:
$data=User::find(Auth::user()->id);
//echo $date;
$data->gender=$request->gender;
$data->name=$request->username;
$data->mobile=$request->mobile;
$data->email=$request->email;
$data->address=$request->address;
$data->image=$request->image;
$data->save;
return redirect()->route('profile.view')->with('success',' User Updated successfuly');
but it doesn't update this record and doesn't receive an Error.
The problem was solved.I dont use "()" end of save ! thanks

How to retrieve a message link if it contains a specific string?

I tried doing something like this
ctx = message
"https://discordapp.com/channels/"+ctx.guild.id+"/"+ctx.channel.id+"/"+ctx.id
"https://discordapp.com/channels/"+guild.id+"/"+ctx.channel.id+"/"+ctx.id
Neither worked
If you're confused, Lets say if the message contains "hi" I want it to copy the message link and post it, so if someone clicks on the link it redirects them to that message
Thank you for reading.
#client.command()
async def keyword(ctx, *, word: str): # Usage: !keyword hi
messages = await ctx.channel.history(limit=200).flatten() # Get last 200 messages
for msg in messages: # Iterate through all messages.
if word in msg.content:
await ctx.send(msg.jump_url) # Send the jump link to the message containing the word.
discord.Message.jump_url
Reference:https://discordpy.readthedocs.io/en/latest/api.html?highlight=jump_url#discord.Message.jump_url

Unable to get proper message Id of message in rocketchat

When i try to send a new message on pressing enter . I am getting message id as "0" when i try to log the message in message.js file . But only for a few messages i am getting id as "0" but database is not showing any entry with message id as "0" .
const {msg} = this;
console.log("tagamsg",msg._id);
id was being set as 0 due to another event that was being called at the same time .

special character in message are encoded when it's delivered

I'm using Laravel-4-Nexmo package to send sms but the message is encoded on delivery .
$receiverNumber = "xxxxxxxxxxx"
$message = "hi from nexmo ? ";
$options = array( 'status-report-req' => 1 );
$Nexmo = Nexmo::sendSMS('me', $receiverNumber , $message , $options);
and received message looks like this :
hi+from+nexmo+%3F+
I would like to receive as
hi from nexmo ?
I look forward to see what could be the solution
Probably the mentioned package does not encode the given message so you should use urlencode($yourString) before using the pacckage
I do not know what was wrong with my code above, and I decided to use similar package and it works now. you can find the package here https://github.com/Artistan/nexmo

Subject in PHPmail $head gets doubled and in wrong encoding

Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg
Here is the PHP code that I use:
$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
$date = date('Y-m-d');
$subject = "Tack för Ert köp! / Thank you for your order!";
$headerFields = array(
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
"From: {$to}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
mail($to, $subject, $message, implode("\r\n", $headerFields));
So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?
You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.
Try passing null as the second argument instead.

Resources