Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: StringCases and Shortest
Replies: 4   Last Post: Mar 12, 2009 3:21 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Grischika@mail.ru

Posts: 23
Registered: 2/5/08
StringCases and Shortest
Posted: Mar 11, 2009 5:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello!
I want to select shortest substring between brackets from the string.
For example:

Func["f(a+b) some text (comments)" ]

should give:

{"a+b","comments"},

and

Func["(f(a+b) some text (comments)" ]

should give:

{"(a+b)","(comments)"} too.

In the help I found this line:

in[]: StringCases["-(a)--(bb)--(c)-", Shortest["(" ~~ __ ~~ ")"]]
out: {"(a)","(bb)","(c)"}

which, at first sight, works as I desire.

But when I add bracket at start of line then answer is incorrect
in[]: StringCases["(-(a)--(bb)--(c)-", Shortest["(" ~~ __ ~~ ")"]]
out: {"(-(a)","(bb)","(c)"}

What is wrong? And how to solve this problem?




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.