22.9 PositionWord

PositionWord( w, sub, from )

PositionWord returns the position of the first occurrence of the word sub in the word w starting at position from. If there is no such occurrence, false is returned. from must be a positive integer. Indexing is done with origin 1.

In other words, PositionWord(w,sub,from) returns the smallest integer i larger than or equal to from such that Subword( w, i, i+LengthWord(sub)-1 ) = sub (see Subword).

    gap> a := AbstractGenerator("a");;
    gap> b := AbstractGenerator("b");;
    gap> w := (a^2*b)^5*b^-1;
    a^2*b*a^2*b*a^2*b*a^2*b*a^2
    gap> PositionWord( w, a^2*b, 2 );
    4
    gap> PositionWord( w, a*b^2, 2 );
    false 

Previous Up Top Next
Index

GAP 3.4.4
April 1997