Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Regular expression

by Samy_rio (Vicar)
on Aug 27, 2007 at 09:33 UTC ( #635256=note: print w/replies, xml ) Need Help??

in reply to Regular expression

Hi Archana, try like this,

use strict; use warnings; my $str ='"Transcription factor" promoter DNA "Transcription factor" p +romoter DNA.'; my @str = split//, $str; my $fla = 1; for (@str){ if (($_ eq "\"") && $fla) { $fla = 0; }elsif (($_ eq "\"") && !($fla)){ $fla = 1; } $_ =~ s/ /\,/ if ($fla); } print join'',@str; __END__ Output: ------- "Transcription factor",promoter,DNA,"Transcription factor",promoter,DN +A.

TIMTOWTDI, we can achieve the expected output using RegExp as of below:

$str =~ s/((?:(?!\").)*)(\"[^\"]+\")((?:(?!\").)*)/ my $fi = $1;my $se = $2; my $th = $3; $fi =~ s| |\,|g;$th =~ s| |\,|g; "$fi$se$th"/egs;

Velusamy R.

eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://635256]
[Corion]: LanX: Ah, yeah - Frankfurt is in the quake region, but at the very border. I think I've never noticed a quake in Frankfurt myself
[marto]: good morning all
[Corion]: On another topic, in the process of Rubber Duck SoPWing, I wrote a post about the best API for generating HTTP requests (not sending them) and while writing it and fleshing out my sample implementation, I came up with some improvements to my ...
[Corion]: ... existing prototype. Cartesian Products will be proud of that module once it gets out ;)
[Corion]: Hi marto ;)
LanX has the same problem with English accents ...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2017-01-18 10:19 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.