Welcome to WebmasterWorld Guest from 54.198.222.129

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Scan string for first (

     
12:00 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Hi,

Can someone tell me the best/fastest way to extract data from a given position.

I have a string...

$string = "My Name (PumpkinHead)";

I need to pull out...

$extract = "(PumpkinHead)";

So really, I need to scan for the first ( then subtract one character position and extract everything after.

Hope that makes sense! Thanks in advance.

12:46 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Regular expressions are what you need - they work like this:


$string = "My Name (PumpkinHead)";
$string =~ /(\(.+?\))/;
$extract = $1;
1:11 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Sorry I thought I posted this in the php section. Has it been moved?
1:14 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Nevermind, I found it!

strpos

 

Featured Threads

Hot Threads This Week

Hot Threads This Month