Hello trashman,
>If I had a string that could contain any combination, or some/none of
[].+-*/ how could I strip off extraneous characters after any of these
characters to get just the left most sub string?
eg
Do.Bears+Defecate*Rurally would give Do
Mostly*Harmless would give Mostly
Don-t/Panic would give Don
You could use this expression:
.*?[\[\]\.+\-*/]
Looks wild - you're scanning for characters that have special meaning in
regular expressions. Also, look only for the first match, as you're not
interested in the rest.
I agree with Göran's suggestion of using string functions instead - not
necessarily because it's easier, I think that's a matter of content and
personal perception, but because regular expressions always incur a
certain overhead. As a basic rule, if there's no particular reason to want
the regular expression, an alternative solution will usually be preferable
to me.
Oliver Sturm
--
http://www.sturmnet.org/blog