
KERNELKLINK
Novice
Dec 11, 2013, 6:10 AM
Post #1 of 18
(5419 views)
|
capture substring with known prefix in middle of string
|
Can't Post
|
|
so I'm using a regex to capture a substring in the middle of a string with a known format. The substring has the prefix "ABC". Here's what I've been trying to do, with no luck: if($line =~ m/insert_pack:(\s*ABC.*)pack_type:/) $var = $1 ----------------------------- I'm basically trying to capture a substring with the prefix "ABC" in the middle of a string that will look like this: insert_pack: ABChello pack_type: b there could be spaces before the "ABC"-prefixed substring as in the example above, so my regex has to capture that too. The problem is that I'm not catching the substring in $1, so my regex is wrong. Anyone know what the correct syntax would be?
|