Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Shambles on August 18, 2018, 03:53:48 PM

Title: What regex would I need to test this string?
Post by: Shambles on August 18, 2018, 03:53:48 PM
Disclaimer: I know the square root of sod all about regular expressions and no amount of searching seems to change that  :-X

Ok, so I have several edits to the Tapatalk code to change the way it works in my forum.

One of the many changes I've made has been to detect and remove the signature applied by the Tapatalk plugin.

I've been using this to great effect so far


$_POST['message'] = preg_replace("/Sent from my (\S*) using Tapatalk/", '', $_POST['message']);


This works a treat as it allows me to detect and remove text such as

Code (examples that work) Select

Sent from my XT108 using Tapatalk
Sent from my CDL-229 using Tapatalk


However it will not detect where the incoming string contains multiple components, such as:

Code (these aren't detected) Select

Sent from my Samsung FunFone using Tapatalk
Sent from my XT560 CCD using Tapatalk



Any regexperts in the house able to assist?

Cheers
Title: Re: What regex would I need to test this string?
Post by: SychO on August 18, 2018, 04:10:25 PM
that's because \S doesn't catch white spaces specifically, this works better
/Sent from my (.*) using Tapatalk/
Title: Re: What regex would I need to test this string?
Post by: Shambles on August 18, 2018, 04:14:55 PM
Works a treat!

Thanks buddy.