in reply to Capitalization and Regex

Use the /i flag like you use the /g. Ex/
sub Regch{ $_[0]=~s/(\.|\-|\(|\)|\[|\]|\{|\}|\?|\/|\\|\^|\*)/\\$1/gi; $_[0]=~s/([a-z])/[$1]/gi; return $_[0]; }
Update Removed character class redundacy. That will teach me to at least look at the regex before posting... ; )

Replies are listed 'Best First'.
Re: Re: Capitalization and Regex
by davido (Cardinal) on Oct 26, 2003 at 22:16 UTC
    $_[0]=~s/([a-zA-Z])/[$1]/gi;

    Of course with the /i modifier, [a-zA-Z] becomes redundant, and so, can be expressed as simply [a-z], assuming we're dealing with ASCII.


    Dave


    "If I had my life to live over again, I'd be a plumber." -- Albert Einstein