Regular expression to split on .

Discussion in 'Perl' started by PC, Apr 13, 2005.

  1. PC

    PC Guest

    Example:

    my $string = abc\def.ghi\jkl

    split( ".", $string) returns an empty list.

    Any idea what I am doing wrong?

    --
    CIA DEA DIA FBI KGB NSA WMD TLA
    PC, Apr 13, 2005
    #1
    1. Advertising

  2. PC wrote:
    > Example:
    > my $string = abc\def.ghi\jkl
    > split( ".", $string) returns an empty list.
    >
    > Any idea what I am doing wrong?


    Well, I would guess yes because apparently you are not happy with the
    result.
    However there is no way of saying what you are doing wrong because you
    didn't tell us what you expect this code to do in the first place.

    jue
    Jürgen Exner, Apr 14, 2005
    #2
    1. Advertising

  3. PC

    PC Guest

    "Jürgen Exner" <> wrote in message
    news:8Oh7e.15003$hB6.8780@trnddc06...
    > PC wrote:
    >> Example:
    >> my $string = abc\def.ghi\jkl
    >> split( ".", $string) returns an empty list.
    >>
    >> Any idea what I am doing wrong?

    >
    > Well, I would guess yes because apparently you are not happy with the
    > result.
    > However there is no way of saying what you are doing wrong because you
    > didn't tell us what you expect this code to do in the first place.
    >
    > jue


    The correct answer was split(/\./, $string)

    Thanks.
    PC, Apr 14, 2005
    #3
  4. 2005-04-13, PC <> ÐÉÛÅÔ:
    > Example:
    >
    > my $string = abc\def.ghi\jkl
    >
    > split( ".", $string) returns an empty list.
    >
    > Any idea what I am doing wrong?
    >


    try this
    perl -le '$a="qwe.rew.sa.ds"; @b=split /\./,$a; print "@b";'

    --
    Alex I. Varyanik -kpi.kiev.ua
    ftp://cono.trinity.ntu-kpi.kiev.ua
    ICQ:102575440
    Alex I. Varyanick, Apr 24, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,261
  2. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Regular Expression to Split Text with \r\n

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Mar 22, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,839
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Mar 22, 2005
  3. Richard
    Replies:
    5
    Views:
    516
  4. rhaavik
    Replies:
    6
    Views:
    4,733
    Hendrik Maryns
    Nov 17, 2005
  5. Chris
    Replies:
    7
    Views:
    936
    Chris
    Sep 8, 2005
Loading...

Share This Page