Current location: Hot Scripts Forums » Programming Languages » PHP » Regular Expressions Problem


Regular Expressions Problem

Reply
  #1 (permalink)  
Old 01-01-05, 12:07 PM
tylerc tylerc is offline
Newbie Coder
 
Join Date: May 2004
Location: Canada
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Regular Expressions Problem

What would be the regular expression be detect the [zone] & [/zone] in line? I also need to be able to know what the word is in the brackets so I can make a variable later. Would Anybody be able to help me?

PHP Code:

<?php


$list 
= array();
$list[] = "[zone]";
$list[] = "value1 data1";
$list[] = "value2 data2";
$list[] = "[/zone]";

foreach(
$list as $line) {
  if (
preg_match("dont know"$line$match) {
     echo 
"Beginning or End of \"" $match[1] . "\" Zone<br>\n";
  }
}
__________________
-Tyler
RuneGuide Owner/Manager

Runescape Stats:
http://www.rsbandb.com/sig/sigs/n/nexon89.png
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-01-05, 02:06 PM
jasong jasong is offline
Wannabe Coder
 
Join Date: Feb 2004
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
The word in the brackets is zone & /zone, I think they are for xml (so they arent variables, just tags)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-01-05, 02:39 PM
tylerc tylerc is offline
Newbie Coder
 
Join Date: May 2004
Location: Canada
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
its not xml, xml has <these tags>, this has [this type] of tags. I want to be able to parse the value out of the brackets whether its a [value] or [/value]
__________________
-Tyler
RuneGuide Owner/Manager

Runescape Stats:
http://www.rsbandb.com/sig/sigs/n/nexon89.png
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-01-05, 04:01 PM
Tarellel Tarellel is offline
New Member
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Post

Umm you may want to try something like this:
Or at least its a start of what you may need.

PHP Code:

<?php

    $string 
"[zone]zoneValue[/zone]";
    
$matchs "";
    
preg_match_all('/\[zone\](.+?)\[\/zone\]/is',$string,$matches);
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-01-05, 05:31 PM
tylerc tylerc is offline
Newbie Coder
 
Join Date: May 2004
Location: Canada
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for helping me out here
__________________
-Tyler
RuneGuide Owner/Manager

Runescape Stats:
http://www.rsbandb.com/sig/sigs/n/nexon89.png
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count problem kasic ASP.NET 1 10-20-04 01:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 10:13 AM
Regular Expression Problem birdy Visual Basic 0 10-04-04 03:09 PM
Regular Expressions Zapatista PHP 7 08-22-04 09:54 AM
Regular Expressions helpcenterlive PHP 2 12-08-03 07:56 PM


All times are GMT -5. The time now is 01:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.