Equivalent of the Mid function from VB?

C

Connell Gauld

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
 
J

Jack Challen

Connell said:
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
 
J

Jürgen Exner

Connell said:
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
 
T

Tore Aursand

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.
[...]
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top