How do I remove specific numbers from a string?

Posted by user1666900 on Stack Overflow See other posts from Stack Overflow or by user1666900
Published on 2012-09-12T20:29:01Z Indexed on 2012/09/12 21:38 UTC
Read the original article Hit count: 195

Filed under:
|

I have this string in PHP

Hopelessly Incredible |SPG:M| 766 STEAM_0:1:20130600 " banned "A Blatantly Obvious Hacker 740 STEAM_0:1:55386073 " (minutes "0") (reason "Multi-Hack")

The Format of the string is: Name1 Number(0-3 digits) Steam_0:x:xxxx offense (banned/kicked/mute etc) Name2 Number(0-3 digits) Steam_0:x:xxxx time reason

My goal is to remove the values 766 and 740 because it is just garbage. Those values can have single, double, and triple digits. The next step would be to strip STEAM_0:1:20130600 and STEAM_0:1:55386073 out of the string and capture it in a new variable. The only constant is STEAM_0: the rest can change.

I am still learning regex but I fear this is a bit complicated for me to do. Some guidance would be most appreciative.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex