homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Scan string for first (
PumpkinHead




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

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.

 

zCat




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

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


$string = "My Name (PumpkinHead)";
$string =~ /(\(.+?\))/;
$extract = $1;

PumpkinHead




msg:436586
 1:11 pm on Apr 5, 2006 (gmt 0)

Sorry I thought I posted this in the php section. Has it been moved?

PumpkinHead




msg:436587
 1:14 pm on Apr 5, 2006 (gmt 0)

Nevermind, I found it!

strpos

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved