Re: Help: Regular expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg123085] Re: Help: Regular expressions
- From: James Stein <mathgroup at stein.org>
- Date: Wed, 23 Nov 2011 07:04:24 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jad600$eig$1@smc.vnet.net> <201111221036.FAA28079@smc.vnet.net>
<oleksandr_rasputinov at hmamail.com> wrote: > If you find regular expressions opaque and difficult to work with (and who > doesn't?) then you might be better off using Mathematica's string pattern > syntax instead. Yes, I've been using regular expressions (infrequently ) for decades, and usually must resort to a reference to do what I wish. For people with MacIntosh computers, the free text editor "TextWrangler" comes bundled with a manual with one or two clear chapters on regular expressions. On Tue, Nov 22, 2011 at 2:36 AM, Oleksandr Rasputinov < oleksandr_rasputinov at hmamail.com> wrote: > On Mon, 21 Nov 2011 09:34:56 -0000, Shizu <slivo.vitz at msa.hinet.net> > wrote: > > > Hello, > > > > Would anybody tell me what's the difference between these two -- > > with amd without "^"? > > Regular expressions are not easy for me! > > > > > > In= StringSplit["line1\nline2\nline3", RegularExpression["(?m)^"]] // > > InputForm > > > > Out= {"line1\n", "line2\n", "line3"} > > > > In= StringSplit["line1\nline2\nline3", RegularExpression["(?m)"]] // > > InputForm > > > > Out= {"l", "i", "n", "e", "1", "\n", "l", "i", "n", "e", "2", "\n", "l", > > "i", > > "n", "e", "3"} > > > > Thanks in advance. > > > > The difference is that the latter is equivalent to > > StringSplit["line1\nline2\nline3", RegularExpression[""]] > > since (?m) is just an option which makes ^ match line beginnings rather > than the beginning of the string as a whole. > > If you find regular expressions opaque and difficult to work with (and who > doesn't?) then you might be better off using Mathematica's string pattern > syntax instead. > >
- References:
- Re: Help: Regular expressions
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
- Re: Help: Regular expressions