On 2013-01-03 17:42, Andy Bach wrote:
s/(i)([0-9]{2})(o)/1${2}0/;
But why capture and don't use?
s/i([0-9]{2})o/1${1}0/;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
> s/(i)(\d\d)(o)/1$20/;
You don't need to capture the "i" or "o"
s/i(\d+)o/1${1}0/
If there were more i or o's, 2 subs
s/i/1/g
s/o/0/g
The "g" globally replacing all the matches. There's probably a tricky way to
do that in one but.
> Since you are capturing 3 groups:
s/(i)([0-9]{2})(o)/
On Thu, Jan 03, 2013 at 03:53:20PM +0530, punit jain wrote:
> Hi,
>
> I am facing issues in parsing using Regex. The problem definition is as
> below : -
> I want to parse it in such a way that all data with BEGIN and END goes in
> one file and BEGINDL and ENDDL goes in other with kind of proces
Hi Punit,
some comments on your code:
On Thu, 3 Jan 2013 15:53:20 +0530
punit jain wrote:
> Hi,
>
> I am facing issues in parsing using Regex. The problem definition is as
> below : -
>
> A file with data :-
>
> BEGIN
> country Japan
> passcode 1123
> listname sales
> contact ch...@example.c
Hi,
I am facing issues in parsing using Regex. The problem definition is as
below : -
A file with data :-
BEGIN
country Japan
passcode 1123
listname sales
contact ch...@example.com
contact m...@example.com
END
BEGIN
country Namibia
passcode 9801
listname dept
contact l...@example.com
END
BEGIN
On 2013-01-02 15:34, Hamann, T.D. wrote:
[...] given a string:
i99o
where I want to replace the 'i' by a '1' and the 'o' by a '0' (zero), the
following regex fails:
s/(i)(\d\d)(o)/1$20/;
Since you are capturing 3 groups:
s/(i)([0-9]{2})(o)/$1$2$3/;
for the obvious reason that perl l
Hamann, T.D. wrote:
Hello,
Hello,
Given a string:
i994
where I want to replace the 'i' by a '1' the following regex
succesfully replaces the letter by a number:
s/(i)(\d\d\d)/1$2/;
tr/i/1/;
However, given a string:
i99o
where I want to replace the 'i' by a '1' and the 'o' by a '0'
Hi,
why not use tr?
$str =~ tr/io/10/;
Brs
想念你的每一天
- 原邮件 -
发件人: "Hamann, T.D."
收件人: "beginners@perl.org"
抄送:
发送日期: 2013年1月2日, 星期三, 10:34 下午
主题: Substituting letters for numbers
Hello,
Given a string:
i994
where I want to replace the 'i' by a '1' the following regex succesful