• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

Perl string parsing

I have a string:

$str = 'JSESSIONID=ABC123; path=/path';

how do I extract 'ABC123' into a new variable?
0
robocop100
Asked:
robocop100
1 Solution
 
jeromeeCommented:
my ($newstr) = ($str =~ /^JSESSIONID=([^;]+);/);
0
 
farzanjCommented:
Try this:

$str =~ /.*=(.*?);.*/;
$var = $1;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now