Home: Perl Programming Help: Regular Expressions:
trimming string



qwe
New User

Jan 14, 2010, 5:20 AM


Views: 5147
trimming string

Hi,
I have some strings eg. 1:10:1:111#3/2 and I would like to get 1:10:1:111 . What is the best way to remove # and all characters after this with RegExp?

Thank you in advance.


toolic
User

Jan 14, 2010, 5:59 AM


Views: 5144
Re: [qwe] trimming string

One way is to use the substitution operator:


Code
$str =~ s/#.*//;


http://perldoc.perl.org/perlop.html