The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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

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

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

should give:



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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.