News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

What regex would I need to test this string?

Started by Shambles, August 18, 2018, 03:53:48 PM

Previous topic - Next topic

Shambles

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

SychO

that's because \S doesn't catch white spaces specifically, this works better
/Sent from my (.*) using Tapatalk/
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Shambles


Advertisement: