PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Sep 21, 2018 9:25 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Escaping in Assertions
PostPosted: Sun Sep 30, 2012 11:52 am 
Offline
Forum Newbie

Joined: Sun Sep 30, 2012 11:42 am
Posts: 1
Hello everybody,

i have the following string:
Syntax: [ Download ] [ Hide ]
Ref-Nr.         : xai2i31iw
 


and i'm trying to get "xai2i31iw" as value with preg_match.

I'm struggling with escaping the Ref-Nr.
i tried the following regex with a look behind assertion:
Syntax: [ Download ] [ Hide ]
#(?<=Ref\-Nr\.\:).*#

But it doesn't work...

I would appreciate every help because i'm pretty new to regular expressions and google / forums search don't bring up any information that help me solving this problem.

Thanks :D

Sythus


Top
 Profile  
 
PostPosted: Sun Sep 30, 2012 12:23 pm 
Offline
Forum Regular
User avatar

Joined: Tue Sep 28, 2010 11:41 am
Posts: 984
Location: Columbus, Ohio
Here is something

Syntax: [ Download ] [ Hide ]
$subject = "Ref-Nr.         : xai2i31iw";

if (preg_match('/Ref-Nr\.\s*?:\s*?([a-z0-9]+)/', $subject, $regs)) {
    $result = $regs[1];
}
else {
    $result = FALSE;
}


A great program for helping with RegEx's is my favorite, RegexBuddy.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group