Equivalent of the Mid function from VB?

Discussion in 'Perl Misc' started by Connell Gauld, May 24, 2004.

  1. Hey,

    I'm trying to grab a section from a piece of text and I was wondering if
    there was an equivalent to Visual Basic's Mid function in perl.
    Basically it takes a start index (as a number of characters from the
    beginning of the string) and a similar end index and returns the text
    between them.

    Thanks
    Connell
    Connell Gauld, May 24, 2004
    #1
    1. Advertising

  2. Connell Gauld

    Jack Challen Guest

    Connell Gauld wrote:
    > I'm trying to grab a section from a piece of text and I was wondering if
    > there was an equivalent to Visual Basic's Mid function in perl.


    yep. substr().

    "perldoc -f substr" for more info
    Jack Challen, May 24, 2004
    #2
    1. Advertising

  3. Connell Gauld wrote:
    > I'm trying to grab a section from a piece of text and I was wondering
    > if there was an equivalent to Visual Basic's Mid function in perl.
    > Basically it takes a start index (as a number of characters from the
    > beginning of the string) and a similar end index and returns the text
    > between them.


    perldoc -f substr

    jue
    Jürgen Exner, May 24, 2004
    #3
  4. Thanks, worked great!


    "Connell Gauld" <> wrote in message
    news:c8t287$jpp$...
    > Hey,
    >
    > I'm trying to grab a section from a piece of text and I was wondering if
    > there was an equivalent to Visual Basic's Mid function in perl.
    > Basically it takes a start index (as a number of characters from the
    > beginning of the string) and a similar end index and returns the text
    > between them.
    >
    > Thanks
    > Connell
    >
    >
    Connell Gauld, May 24, 2004
    #4
  5. Connell Gauld

    Tore Aursand Guest

    On Mon, 24 May 2004 15:58:28 +0100, Connell Gauld wrote:
    > I'm trying to grab a section from a piece of text and I was wondering if
    > there was an equivalent to Visual Basic's Mid function in perl.
    > Basically it takes a start index (as a number of characters from the
    > beginning of the string) and a similar end index and returns the text
    > between them.


    perldoc -f substr

    substr EXPR,OFFSET,LENGTH,REPLACEMENT
    substr EXPR,OFFSET,LENGTH
    substr EXPR,OFFSET
    Extracts a substring out of EXPR and returns it. First charac-
    ter is at offset 0, or whatever you've set $[ to (but don't do
    that). If OFFSET is negative (or more precisely, less than
    $[), starts that far from the end of the string. If LENGTH is
    omitted, returns everything to the end of the string. If
    LENGTH is negative, leaves that many characters off the end of
    the string.
    [...]


    --
    Tore Aursand <>
    "Why shouldn't truth be stranger than fiction? Fiction, after all, has
    to make sense." (Mark Twain)
    Tore Aursand, May 24, 2004
    #5
    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. MarkD
    Replies:
    0
    Views:
    738
    MarkD
    Dec 4, 2003
  2. MJB
    Replies:
    0
    Views:
    305
  3. bruce barker
    Replies:
    2
    Views:
    360
    bruce barker
    Aug 23, 2004
  4. Joeandtel

    problem with mid() function

    Joeandtel, Nov 14, 2003, in forum: ASP General
    Replies:
    3
    Views:
    102
    Evertjan.
    Nov 14, 2003
  5. Ken VdB

    Mid() function crippled?

    Ken VdB, Apr 2, 2004, in forum: ASP General
    Replies:
    10
    Views:
    316
    Joe Earnest
    Apr 4, 2004
Loading...

Share This Page