Page 1 of 1

Escaping in Assertions

Posted: Sun Sep 30, 2012 11:52 am
by Sythus
Hello everybody,

i have the following string:
[text]
Ref-Nr. : xai2i31iw
[/text]

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: [text]#(?<=Ref\-Nr\.\:).*#[/text]
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

Re: Escaping in Assertions

Posted: Sun Sep 30, 2012 12:23 pm
by twinedev
Here is something

Code: Select all

$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.