如何从默认标量中提取字符串. [英] How to extract string in from a default scalar.

查看:173
本文介绍了如何从默认标量中提取字符串.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我在perl中有这个小代码,现在我非常确定该怎么做.我已经从csv文件int0 $ _中读取了一行,现在我需要从中提取字符串的一部分.

CSV文件中的前行将是
一;二;三;四;五;六

我需要有一个变量(标量)才能具有值
fourfive

(在四到五个之间没有分号)
我尝试了模式匹配,但没有得到正确的结果
可以提供任何帮助.

Hello,
I have this small code to do in perl and i am now very sure of how to do it. I have read a line from the csv file int0 $_and now i need to extract a part of the string from it.

Ex line in csv file would be
one;two;three;four;five;six

and i need to have a variable (a scalar) to have the value
fourfive

(without the semicolon between four and five)
i tried with pattern matching but didnt get the proper results
can any one help.

推荐答案

_,现在我需要从中提取字符串的一部分.

CSV文件中的前行将是
一;二;三;四;五;六

我需要有一个变量(标量)才能具有值
fourfive

(在四到五个之间没有分号)
我尝试了模式匹配,但没有得到正确的结果
谁能帮忙.
_and now i need to extract a part of the string from it.

Ex line in csv file would be
one;two;three;four;five;six

and i need to have a variable (a scalar) to have the value
fourfive

(without the semicolon between four and five)
i tried with pattern matching but didnt get the proper results
can any one help.


您需要的是:

What you need is this:


info =一个;两个;三个;四个;五个;六个;" @items = split(/;/,
info = "one;two;three;four;five;six;" @items = split(/;/,


这篇关于如何从默认标量中提取字符串.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆