This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regex problem

Old posts that have not been replied to for several years.
Locked
User avatar
ex
Voice
Posts: 14
Joined: Wed May 18, 2005 11:04 pm
Location: Chicago

regex problem

Post by ex »

hi i'm having a problem with regex

Code: Select all

return [regexp "^.*test(.+?)test.*" "testlalatest"]
returns 1.
so far so good.

but if i extend the string an the matchstring it is not working anymore.

Code: Select all

#normally the code is in one line - but it's much more easy to read now :)#
return [regexp 
"^.*<td><a class=\"orangelink\" href=\"/news/showdetail.aspx?news_id=1\">test(.+?)test.*" 
"<td><a class=\"orangelink\" href=\"/news/showdetail.aspx?news_id=1\">testlalatest"
]
as you can see ... i just added sume htmlstuff in the front. but suddenly it returns 0


is there a limit of the stringlength or did i something wrong?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you forgot to escape "?" in the html code. btw. you should use {} braces around the re expressions, this makes even the escaping of the " quotes redudant ;).
besides... whats the meaning of "?" in "(.+?)"?
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

the ? it makes it stop after the first match.
User avatar
ex
Voice
Posts: 14
Joined: Wed May 18, 2005 11:04 pm
Location: Chicago

Post by ex »

argh. damn must have overseen it in the manual.


grml then it is quite clear why i tried 4 hours with no result.
User avatar
ex
Voice
Posts: 14
Joined: Wed May 18, 2005 11:04 pm
Location: Chicago

Post by ex »

Code: Select all

return [regexp 
{</tt>: <a class="link" href="http://www.eggheads.org/redirect.php?url=(.+)">(.+)</a>} 
{004 ]</tt>: <a class="link" href="http://www.eggheads.org/redirect.php?url=http://www.eggheads.org/news/2004/08/23/31">Eggdrop 1.6.17 released</a><br} 
tmp url news];
ok i changed it. but still it returns 0 after entering long strings.



the following works fine:

Code: Select all

return [regexp {lala(.+)la(.+)a} {lala123lala}]
User avatar
ex
Voice
Posts: 14
Joined: Wed May 18, 2005 11:04 pm
Location: Chicago

Post by ex »

solved.
the { } still needs the escape of ?

i missunderstood this.


thank you all
Locked