in reply to Re^2: how to split a string at [ ?
in thread how to split a string at [ ?
Yes, see perlre on how "alternations" work:
$temp =~ /(BCInletTemperature|someOtherTemperature|aThirdTemperatu +reName) = ([\d.]+)\[C\]/ or die "Invalid temperature format in '$temp'"; my( $temperatureType, $temperatureValue ) = ($1,$2);
But maybe you want a more generic parser that will capture any word on the left hand side of the "=" sign and any number on the right hand side. Then you can use the \w character class or the [A-Za-z] character class (again, see perlre) for matching any word on the left hand side:
$temp =~ /(\w+) = ([\d.]+)\[C\]/ or die "Invalid temperature format in '$temp'"; my( $temperatureType, $temperatureValue ) = ($1,$2);
|
|---|