(no subject)



There is a package for string processing. See the German documentation
chapter  73. And there is a undocumented package for regex. You will
find some examples in the file share/stringproc/sregex.lisp in the
source code.

A short example session:

(%i1) load(sregex);
(%o1)     /usr/local/share/maxima/5.29.1/share/stringproc/sregex.lisp
(%i2) str : "2*a^3+4*b^2+4*c"$

(%i3) regex_match("[a-z]\\^[0-9]+", str, 1);
(%o3)                                [a^3]
(%i4) regex_match_pos("[a-z]\\^[0-9]+", str, 1);
(%o4)                              [[3, 6]]
(%i5) substring(str, 3, 6);
(%o5)                                 a^3
(%i6) substring(str, 6);
(%o6)                             +4*b^2+4*c
(%i7) regex_match_pos("[a-z]\\^[0-9]+", str, 6);
(%o7)                              [[9, 12]]
(%i8) substring(str, 9, 12);
(%o8)                                 b^2

Are you sure you want regex? It is also possible to parse your string.
Then you can use all the available functions for expressions. E.g.

(%i9) expr : parse_string(str);
                                        2      3
(%o9)                          4 c + 4 b  + 2 a
(%i10) display2d : false$

(%i11) expr : parse_string(str);

(%o11) 4*c+4*b^2+2*a^3
(%i12) coeff(expr, a^3);

(%o12) 2

Hope that helps to get started.

Volker van Nek

2013/1/8 Sean <seany at uni-bonn.de>:
> Hello all
>
> Wish you all a happy new year, if you follow the European/Georgian Calendar
> System ..
>
> I would like to know more about the regular expression search in maxima.
>
> Say i have a string "abcdefghijkl...."
>
> Starting at index I, in the direction forward or backward, i want to find a
> substring in form A^n B^m ..
>
> where A in {a,b,c,...,z}, 0<= n<= 1, m >= 1, etc (the exact reqs would of
> course depend on the problem in hand)..
>
> Where do I start, google does not seem to be much helpful, and i am kind of
> lost in the "The Maxima Book".
>
> Please help, Sorry for my bad Englisch.
>
> Regards from Germany
> Sean
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima