in reply to Capturing everything after an optional character in a regex?

It usually helps to rephrase what you are looking for. In your case, if I've understood your clarification elsewhere in this thread, you want to capture "all of the non-X characters at the end of the string." In code, that's /([^X]*)$/ and here it is in action:

$ perl -le '$_ = "abcX123"; print $1 if /([^X]*)$/;' 123 $ perl -le '$_ = "abc123"; print $1 if /([^X]*)$/;' abc123

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Capturing everything after an optional character in a regex?
by allolex (Curate) on Dec 04, 2003 at 09:49 UTC

    Simple, elegant.

    I just realized I'd been sitting on a reply for about an hour. :/

    --
    Allolex