regular expression help

Discussion in 'Perl Misc' started by uttam h, Nov 16, 2004.

  1. uttam h

    uttam h Guest

    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
    uttam h, Nov 16, 2004
    1. Advertisements

  2. 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...

    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";
    Tad McClellan, Nov 16, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.