in reply to Extracting two numbers from a string
A regular expression will likely do what you want:
my $string = 'examplestringofrandomlength/userid=6&refid=49'; my ($num1, $num2) = $string =~ /\d+/g;
See perlretut, in particular Using regular expressions in Perl.
Note that given the simplicity of this expression, it can fail in many ways - for example, if your string is really stringwithnumber111/userid=6&refid=49, you'll get the wrong result. If this is an issue, post a more accurate and complete set of sample strings.
|
|---|