in reply to Quick regex substitution question

You need to search for "look-ahead assertion" in the docs.

As I am no master of this I would do $string =~ s/;(.)/$1/g; assuming that the semikolon is the last character in the string.

Replies are listed 'Best First'.
Re^2: Quick regex substitution question
by jmmach80 (Initiate) on May 29, 2015 at 14:18 UTC

    Yeah I've been trying to implement a look-ahead assertion, but it's not working. I been trying something like this...

    $string =~ s/\;(?!\;$)//g;

    I thought it would find all occurrences of ; but not the last one followed by end-of-line, but it's not working. There's something I don't understand.

      Part of your problem is your attempt to escape the semicolons. They're NOT end_of_statement markers to Perl or its regex engine when inside a quoted string. You may also want to read about using '!' as a negation.