regular expression help

U

uttam h

hi all,
i just strated learning regular expression.i need a PERL-regular
expression for the following problem.
input string $string['bababa']='jajaja';
output bababa jajaja
thanx in advance
u h

Post a foll
 
T

Tad McClellan

uttam h said:
input string $string['bababa']='jajaja';
output bababa jajaja


Here are half a dozen ways to get that.

The value of an answer is directly proportional to the care
given in asking the question...


-----------------------
#!/usr/bin/perl
use warnings;
use strict;

$_ = q($string['bababa']='jajaja');

my @matches = /([abj]+)/g;
print "@matches\n"; # only the "good" letters

@matches = /'([^']+)'/g;
print "@matches\n"; # single quoted

@matches = /(\w+a)/g;
print "@matches\n"; # ends with "a"

@matches = /(\w+)'/g;
print "@matches\n"; # ends with "'"

print substr($_, 9, 6), ' ', substr($_, 19, 6), "\n"; # no regexes at all!

tr/=/ /; # this one's *not* a regex
s/[^abj ]+//g; # but part of this one is
print "$_\n";
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top