Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 26-01-2006, 09:32 AM   #1
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

I'm learning Regex now, and'm quite stumped. I'd ask the instructor, but he's said to be no good with them either yesterday. I've made a test-page to get the hang of it, but its output's not what it should do, according to how I read the code.

Code:
 *$string = "Best niet [b] bevet Moddervet Niet vet";
 *echo $string, "<br>";

 *eregi("(\[b\])", $string, $resultaat);
 *$open_tags = count($resultaat);

 *eregi("(\[/b\])", $string, $resultaat_closed);
 *$closed_tags = count($resultaat_closed);

 *echo "Open: ", $open_tags, "<br>Closed: ", $closed_tags;
That's my code (stripped of all set-up tags like <html> etc). This's its output:
Code:
Best niet [b] bevet Moddervet Niet vet
Open: 2
Closed: 0
No matter how many results it should find, it'll always give 2, except if there're no results, like in Closed. Then it'll give 0. I don't see why it doesn't give 1 for the Open one in the current example. Any help'd be greatly appreciated
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
 


Similar Threads
Thread Thread Starter Forum Replies Last Post
regular sgtboat Blah, blah, blah... 4 26-11-2008 03:30 AM
When will regular updates start? Doink Blah, blah, blah... 6 13-12-2007 10:00 AM


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 08:11 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.