Re: [PHP] ereg() problem



jekillen wrote:
Hello php list;

I am having trouble with ereg().
The following is the problem code
$x = ereg("<route name='$to' x='../(.*)/in' rec='.*' />", $get_route, $m);
do we need to break out of the text to include the $to variable??

testing $route I get:
do you mean $get_route?

$route = $m[1];
print $route.'<br>';
jk/in' rec='a_378e6dc4.xml' /> (out put of print)
Is this an example of th input?

What does an actual line of $get_route look like?

do a var_dump($m); and show output

jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK


or better yet, try this

I am assuming on the actual structure of $get_route but the following return to me $match[1] = '../jk'

$to = 'something';
$get_route = "<route name='something' x='../jk/in' rec='998asdf' />";
preg_match("|<route name='".$to."' x='(\.\./.*)/in' rec='.*' />|", $get_route, $matches);
var_dump($matches);



--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree.

- Rush
.



Relevant Pages

  • about figure placement in a two column landscape document
    ... I'm formatting a two column landscape document, ... trouble with figures. ... This document has a cover image (a PNG file), ...
    (comp.text.tex)
  • ereg() problem
    ... I am having trouble with ereg. ... The following is the problem code ... testing $route I get: ... work without this sort of trial and error. ...
    (php.general)
  • Re: Word 2004 delete multiple unwanted styles
    ... I use this method a lot also; the trouble was in this ... instance I need to preserve some of the author's formatting, ... But this macro gives me a "cleaner slate" from which to work. ...
    (microsoft.public.mac.office.word)
  • Pasting Word 03 Doc in OLE
    ... but I want to better under stand why OLE ... gives me trouble if I try to paste it into a Create Mail space. ... I also got an active x not activated formatting may be distorted message, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: How to get terminal dimensions without using curses or ncurses?
    ... formatting, without going to the trouble of learning curses. ... simply need to know the dimensions of the terminal, ...
    (comp.lang.ruby)