RE: Split question

From: Wiggins D Anconia (wiggins_at_danconia.org)
Date: 12/15/03


Date: Mon, 15 Dec 2003 08:32:19 -0700
To: beginners@perl.org


> On Monday, December 15, 2003 03:05, John W. Krahn wrote:
>
> >Here is a little quiz for you beginners out there. split() treats its
> >first argument as a regular expression. There are TWO exceptions where
> >the first argument does not behave the same as a normal regular
> >expression. What are they?
>
> The first one that comes to mind is using // for your search. Rather than
> repeating the last search, it searches for the null string to split on.
>
> The second one is if you include parentheses in your regex. If you put
> parentheses around your regex, then split will create entries for each of
> the matched terms in addition to the just the "splitted" items.
>
> So, do I win a prize or something? :)
>

But parentheses are normal in a regex, though granted the return is odd.
I would guess as the second the special case where ' ' is passed and the
string is split on whitespace which is not interesting, but where
leading space is skipped?

http://danconia.org

--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.


Relevant Pages

  • Re: regex problem unresolved
    ... makes regex fail, I might have already solved half of the problem. ... data file confirmed by search, I believe the fetch program first grabs all ... You have a file 1 from which you read a string, ... the regular expression make it look a bit like that). ...
    (comp.lang.perl.misc)
  • Re: Which RegEx Testing Tool Do You Prefer?
    ... public static string ReplaceAmpersand ... I used both Expresso and Regex Buddy to come up with this. ... > have to force the 2.0 Regular Expression Validator to fail when the & is ... >> create patterns of a large variety of types. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RegExp to capture IMAGE SRC only.
    ... OBJECT's SRC. ... You will have to define the expected string clearly. ... So you will have to fine tune your regex again and again, ... I put your regular expression in both The Regex Coach, ...
    (comp.lang.javascript)
  • Re: Printing regex match
    ... As long as there is only a single string to be captured, ... You need matching parentheses in the regex. ...
    (comp.lang.perl.misc)
  • Re: Regular expression question
    ... Your regular expression isn't matching the object string. ... use warnings; ... Changing the regex to this ...
    (perl.beginners)