in reply to How do i get string between
but doesn't seem to be working. What am I doing wrong?
"not working" can mean a lot of things to a lot of people. Please take a look at I know what I mean. Why don't you? or How do I post a question effectively? so we can better understand your issue. Posting code with sample input and expected output is very helpful in diagnosing problems.
Based on what you've posted, I'm guessing the issue you are having is with greedy matching. .* matches as much as it can, whereas .*? grabs the shortest string that meets the criteria. So perhaps the code
($content) = $item1 =~ m/\/(.*?)\?/;
does what you intend? See perlretut for more info.
Also possibly at fault is white space I see in your posted expression. Of course, that might just be an artifact of the fact that you didn't wrap your code in <code> tags; see Writeup Formatting Tips.
|
|---|