Urgent!!! Regular expression??

Discussion in 'Perl' started by psk, Aug 13, 2003.

  1. psk

    psk Guest

    I need a regular expression for replacing each character in a text
    with an X.

    For example,

    ASASasdfdfDFDFDFDFAAAAAAAAAAAAAAAAAAAAAAABNNBMBMBMBMBBNBJFFFJFFHFFJFJFJJFJFJFJFJFJFJFJFWEWEW

    is the initial string i want to replace the 12 A's followed by
    something with X's

    something like AAAAAAAAAAAAAAAA.* to be replaced by an equal number of
    X's

    so output should be

    ASASasdfdfDFDFDFDFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thanx for ur help.
    psk, Aug 13, 2003
    #1
    1. Advertising

  2. psk

    dw Guest

    "psk" <> wrote in message
    news:...
    > I need a regular expression for replacing each character in a text
    > with an X.
    >
    > For example,
    >
    >

    ASASasdfdfDFDFDFDFAAAAAAAAAAAAAAAAAAAAAAABNNBMBMBMBMBBNBJFFFJFFHFFJFJFJJFJFJ
    FJFJFJFJFJFWEWEW
    >
    > is the initial string i want to replace the 12 A's followed by
    > something with X's
    >
    > something like AAAAAAAAAAAAAAAA.* to be replaced by an equal number of
    > X's
    >
    > so output should be
    >
    >

    ASASasdfdfDFDFDFDFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXX

    how about:
    $_ =
    'ASASasdfdfDFDFDFDFAAAAAAAAAAAAAAAAAAAAAAABNNBMBMBMBMBBNBJFFFJFFHFFJFJFJJFJF
    JFJFJFJFJFJFWEWEW';

    s/(A{12}.*)/"X" x length $1/e;
    dw, Aug 13, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,261
  2. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    823
    Alan Moore
    Dec 2, 2005
  3. GIMME
    Replies:
    3
    Views:
    11,909
    vforvikash
    Dec 29, 2008
  4. Robert Brewer
    Replies:
    1
    Views:
    355
    Colin Brown
    Feb 23, 2004
  5. Eric @ Zomething
    Replies:
    0
    Views:
    351
    Eric @ Zomething
    Feb 23, 2004
Loading...

Share This Page