Page 1 of 1

exp with stack

Posted: Wed Apr 29, 2009 9:12 am
by michalmas
Hello,

Can anyone help me with the following problem:

I have text:

Code: Select all

   some text is here ble bla blu
    now there is some structure
    [b]struc [/b]something
    now we are inside and next element:
    [b]elem [/b]value
    something els, and again
    [b]elem [/b]val2
    [b]end struc[/b]
    this is not inside
    elem valXXX
and i want to extract all elem elements that are inside some other struc element.

So, the output of the example above is:

elem value
elem val2


but not
elem valXXX.


Any solution (or attempt) close to the result will make me happy.


Thanks!

Re: exp with stack

Posted: Wed Apr 29, 2009 9:47 am
by prometheuzz
---

Re: exp with stack

Posted: Wed Apr 29, 2009 10:06 am
by michalmas
does it match also to many struck-end struck occurances?:

Code: Select all

    
     some text is here ble bla blu
     now there is some structure
     struc something
     now we are inside and next element:
     elem value
     something els, and again
     elem val2
     end struc
     this is not inside
     elem valXXX
     struck 2
     elem val3
     xxxx
     end struck
 
and is it possible to limit to one expression what you wrote and the additional condition:
that element after the elem node contains val?

thx

Re: exp with stack

Posted: Wed Apr 29, 2009 10:32 am
by prometheuzz
michalmas wrote:does it match also to many struck-end struck occurances?:

Code: Select all

    
     some text is here ble bla blu
     now there is some structure
     struc something
     now we are inside and next element:
     elem value
     something els, and again
     elem val2
     end struc
     this is not inside
     elem valXXX
     struck 2
     elem val3
     xxxx
     end struck
 
and is it possible to limit to one expression what you wrote and the additional condition:
that element after the elem node contains val?

thx
Why don't you give it a try...

Re: exp with stack

Posted: Wed Apr 29, 2009 10:34 am
by michalmas
I don't have access to php parser now...

btw: what about the second part of the question:

and is it possible to limit to one expression what you wrote and the additional condition:
that element after the 'elem' node contains 'val' inside?

thx

Re: exp with stack

Posted: Wed Apr 29, 2009 10:48 am
by prometheuzz
michalmas wrote:I don't have access to php parser now...

...
Then I'll wait until you get access to PHP and have tried a couple of things yourself.

Good luck.

Re: exp with stack

Posted: Mon May 04, 2009 3:02 pm
by michalmas
I have problem with enriching the expression. I'd like to make it much more complex:

Code: Select all

 
     some text is here ble bla blu
     some text is here ble bla blu
     START
     some text is here ble bla blu
     * here i ignore the text
     now there is some structure
     struc something
     now we are inside and next element:
     elem value
     something els, and again
     elem val2
     * elem ignored
     end struc
     this is not inside
    * struc sth
    * but it was ignored
     elem valXXX
    *end struc
 
I take only the thing that appear after the START element. So, if there is struc before, it must be ignored.
Next to it, all lines that start with * should be ignored.

The expected output is the same as last time.

I tried with ^ and $, but couldn't make it working with lookaheads. Can you show the solution in one reg exp? If not, can you split it to two but still only using reg exp (without any pre- or post-processing of the text).

@prometheuzz
Yes, i created some more posts on different forums. I did it because i am interested in any possible solution to the problem. Maybe someone could present something more complex but without lookahead (or only with the positive/negative). The problem here is quite serious - it is on the border of the reg exp possibilities. However, it is still possible to create the finite-states automaton for the problem, so the solution in reg exp must exist.
Then I'll wait until you get access to PHP and have tried a couple of things yourself.

Good luck.
I had problems with php server on my PC with Windows and i didn't have the possibility to connect to any server with php at that certain time.

Re: exp with stack

Posted: Mon May 04, 2009 3:34 pm
by prometheuzz
@michalmas, perhaps someone else is willing to give you a hand, but I've lost interest.
I simply don't like it when people post their problems all over different forums without mentioning they do so: in my opinion, that's just wasting other people's time and it doesn't show much appreciation.

Re: exp with stack

Posted: Mon May 04, 2009 3:41 pm
by michalmas
@prometheuzz:
I regret it, but i understand your point.

However, note that it is not always welcome to share links to other forums.

Thanks,
Michal

Re: exp with stack

Posted: Tue May 05, 2009 6:10 pm
by michalmas
Anyone?

Or, if someone tried but has not succeeded, it will be also useful information.

Thanks,
M.